Skip to content
Advertisement

Why can’t I replace Ellipsis using `pd.DataFrame.replace`?

I have this following pd.DataFrame:

JavaScript

I am trying to replace the Ellipsis with 1.

I know I could do something like:

JavaScript

But, for some reason. If I do:

JavaScript

Or:

JavaScript

I get the following error:

JavaScript

Why doesn’t replace allow me to replace Ellipsis?

I know how to fix it, I want to know why this happens.


The strange thing here is that, I actually can replace numbers with Ellipsis, but not vice versa.

Example:

JavaScript

The even stranger thing here mentioned by @jezrael and @phœnix is that:

JavaScript

Also:

JavaScript

As well as:

JavaScript

And:

JavaScript

Work as expected!

It gives:

JavaScript

Advertisement

Answer

In my opinion it is bug, so reported BUG: Can’t I replace Ellipsis in DataFrame.replace like scalar #50373 .

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement