Skip to content

Commit

Permalink
make string column are writable when reading from parquet (#59)
Browse files Browse the repository at this point in the history
* make string column are writable when reading from parquet

* pep8
  • Loading branch information
sstruzik authored Sep 12, 2023
1 parent 49f89c1 commit 71069fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions ods_tools/oed/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def as_oed_type(cls, oed_df, column_to_field):
to_tmp_dtype[column] = 'str'
if oed_df[column].dtype.name == 'category' and '' not in oed_df[column].dtype.categories:
oed_df[column] = oed_df[column].cat.add_categories('')
oed_df[column] = oed_df[column] # make a copy f the col in case it is read_only
oed_df.loc[oed_df[column].isin(BLANK_VALUES), column] = ''
elif pd_dtype[column].startswith('Int'):
to_tmp_dtype[column] = 'float'
Expand Down
12 changes: 6 additions & 6 deletions tests/test_ods_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ def test_relative_and_absolute_path(self):
with tempfile.TemporaryDirectory() as tmp_dir:
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()
with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10.csv') as response,\
with urllib.request.urlopen(base_url + '/SourceLocOEDPiWind10.csv') as response, \
open(pathlib.Path(tmp_dir, 'SourceLocOEDPiWind10.csv'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)
with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response,\
with urllib.request.urlopen(base_url + '/SourceAccOEDPiWind.csv') as response, \
open(pathlib.Path(abs_dir, 'SourceAccOEDPiWind.csv'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down Expand Up @@ -477,7 +477,7 @@ def test_setting_schema_analysis__is_valid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand All @@ -499,7 +499,7 @@ def test_setting_schema_analysis__is_invalid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'analysis_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down Expand Up @@ -529,7 +529,7 @@ def test_setting_schema_model__is_valid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand All @@ -551,7 +551,7 @@ def test_setting_schema_model__is_invalid(self):
abs_dir = pathlib.Path(tmp_dir, "abs")
abs_dir.mkdir()

with urllib.request.urlopen(file_url) as response,\
with urllib.request.urlopen(file_url) as response, \
open(pathlib.Path(tmp_dir, 'model_settings.json'), 'wb') as out_file:
shutil.copyfileobj(response, out_file)

Expand Down

0 comments on commit 71069fc

Please sign in to comment.