diff --git a/ods_tools/oed/source.py b/ods_tools/oed/source.py index 128e0178..a91ad2b2 100644 --- a/ods_tools/oed/source.py +++ b/ods_tools/oed/source.py @@ -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' diff --git a/tests/test_ods_package.py b/tests/test_ods_package.py index 664db73f..524a2e19 100644 --- a/tests/test_ods_package.py +++ b/tests/test_ods_package.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)