Skip to content

fillna(inplace=True) does not work with columns selected by loc #32203

@WenjieDu

Description

@WenjieDu

not only multiple columns, but also one column.
df.loc[df.id==123, 'num'].fillna(0, inplace=True) doesn't work ,
but df.loc[df.id==123, 'num'] = 123 works

why not edit the fillna function to adapt it in the future.
It seems like a bug.

Originally posted by @shuiyuejihua in #14858 (comment)

Hi, I met with the same problem. Now that df.loc[df.id==123, 'num'] = 123 works, which means the operation takes effect on original df, why fillna(inplace=True) doesn't work? This is really wired , and seems haven't been fixed. My pandas version is 0.25.3.

Any comment or explaination are welcome, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions