open-sdg / sdg-build

Python package to convert SDG-related data and metadata between formats
MIT License
6 stars 22 forks source link

Error when using code_map in inputs #321

Closed brockfanning closed 1 year ago

brockfanning commented 1 year ago

Pandas 1.4 introduced a breaking change in the Series.replace method. If you are using Pandas 1.4 or higher and try to use the code_map parameter, you'll see this error: ValueError: Series.replace cannot use dict-like to_replace and non-None value. More info on the bug here: https://github.com/pandas-dev/pandas/issues/46004

I'm not sure if Pandas is going to revert their breaking change (they should IMO, since it was introduced in a minor version), but we need to adjust our code in the meantime. The work-around in the meantime is to not specify the value parameter at all. But, we still need it for previous versions of Pandas... So we will need to do a try/except and use both.