Open Ynjxsjmh opened 2 years ago
take
Thanks @Ynjxsjmh for the report and investigation.
This does appear buggy.
as a workaround, changing the LHS to be a DataFrame seems to align with the RHS without issue.
df.loc[df.HomePlanet == 1, ["RoomService"]] = df.fillna(135)
contributions and PRs welcome.
Pandas version checks
[ ] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Original issue occurs in Incompatible indexer with DataFrame - Stack Overflow, following is a reproducible example
Issue Description
Here OP wants to fill the NaN in
RoomService
column based on condition, so he trieswhich throws error
Expected Behavior
Expected output is below
The
ValueError
wouldn't appear if there is noNaN
inHomePlanet
columnWith further experiment, I find that the error even could be reproduced by removing the NaN in
HomePlanet
columnInstalled Versions