Skip to content

DataFrame.where does not work as expected with inplace=True #7656

Closed
@rockg

Description

@rockg

related #4667, #7647

According to the documentation, inplace should replace values appropriately with other, but this does not seem to work as expected. This worked in 0.12.

In [6]: df = pandas.DataFrame([{'A': 1, 'B': np.nan, 'C': 'Test'}, {'A': np.nan, 'B': 'Test', 'C': np.nan}])

In [7]: df
Out[7]: 
    A     B     C
0   1   NaN  Test
1 NaN  Test   NaN

In [8]: df1 = df.where(~pandas.isnull(df), None)

In [9]: df1
Out[9]: 
      A     B     C
0     1  None  Test
1  None  Test  None

In [10]: df.where(~pandas.isnull(df), None, inplace=True)

In [11]: df
Out[11]: 
    A     B     C
0   1   NaN  Test
1 NaN  Test   NaN

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignDocsIndexingRelated to indexing on series/frames, not to indexes themselvesMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions