DataFrame.where does not work as expected with inplace=True · Issue #7656 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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