Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make string column are writable when reading from parquet #59

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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