Skip to content

Commit

Permalink
better errors for safe convert
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanAugust authored Jun 1, 2024
1 parent e9c6384 commit 55566f5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cheetahpy/local_opendata.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ def _safe_convert(original_series:pd.Series, type_convert:type) -> pd.Series:
new_series = original_series.astype(type_convert)
return new_series
except Exception as err:
print(f'{err}: cannot convert {type(original_series)} to type {type_convert}')
a_value = original_series.dropna().tolist()
if len(a_value) > 0:
a_value_type = type(a_value[0])
else:
a_value_type = "UNKNOWN"
print(f'{err}: cannot convert {original_series.name} (of type: {a_value_type}) to type {type_convert}')
return original_series

@staticmethod
Expand Down

0 comments on commit 55566f5

Please sign in to comment.