You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use df.A.replace(dct), it seems as though the replacement is being applied recursively, and updating until no matches can be found. Here is the output I am currently getting:
>>>df.A.replace(dct)
0hello1hello2helloName: A, dtype: object
As you can see it seems like a is replaced by b is replaced by hello, instead of the single replacement I would expect. I looked through the documentation for replace, and saw nothing that claimed this was intended.
Expected Output
I would expect the output to be the same as df.A.map(dct)
Can confirm it works as expected on master. I believe it may be the same issue as #20656, which I didn't notice before. If so, this issue should be closed.
Here's an easy to produce example:
Problem description
When I use
df.A.replace(dct)
, it seems as though the replacement is being applied recursively, and updating until no matches can be found. Here is the output I am currently getting:As you can see it seems like
a
is replaced byb
is replaced byhello
, instead of the single replacement I would expect. I looked through the documentation forreplace
, and saw nothing that claimed this was intended.Expected Output
I would expect the output to be the same as
df.A.map(dct)
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: