-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
BugCopy / view semanticsRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version
Milestone
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd import numpy as np pdf = pd.DataFrame({"x": [np.nan, 2, 3, 4, np.nan, 6], "y": [np.nan, 2, 3, 4, np.nan, 6]}) pser = pdf.x # Didn't make a copy write to existing (it's unexpected behavior) pdf.fillna(0, inplace=True) >>> pser 0 0.0 1 2.0 2 3.0 3 4.0 4 0.0 5 6.0 import pandas as pd import numpy as np pdf = pd.DataFrame({"x": [np.nan, 2, 3, 4, np.nan, 6], "y": [np.nan, 2, 3, 4, np.nan, 6]}) pser = pdf.x # Make a copy and doesn't write to existing (it's expected behavior) >>> pdf.fillna({"x": -1, "y": -2}, inplace=True) >>> pser 0 NaN 1 2.0 2 3.0 3 4.0 4 NaN 5 6.0 Name: x, dtype: float64Issue Description
Looks like behavior is a little bit differet in current pandas.
Expected Behavior
Always make a copy and doesn't write to existing array for Do in-place operation in all functions with inplace (such like eval/update/fillna).
Installed Versions
1.4+
Metadata
Metadata
Assignees
Labels
BugCopy / view semanticsRegressionFunctionality that used to work in a prior pandas versionFunctionality that used to work in a prior pandas version