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.
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/46004I'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.