-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: NDFrame fillna method add use case #39109
Conversation
pandas/core/generic.py
Outdated
@@ -6362,6 +6360,16 @@ def fillna( | |||
1 3.0 4.0 NaN 1 | |||
2 NaN 1.0 NaN 5 | |||
3 NaN 3.0 NaN 4 | |||
|
|||
Replace with a DataFrame with the same column name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be clarified - replacement happens along same column names and same indices. Maybe the example df2
could also have a column with a different name, such as columns=list("ABCE")
so it's clear that replacement only happens for the columns they have in common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, now corrected
pandas/core/generic.py
Outdated
@@ -148,7 +148,6 @@ | |||
you to specify a location to update with some value.""", | |||
} | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this? could unrelated changes be reverted please?
pandas/core/generic.py
Outdated
@@ -6362,6 +6362,16 @@ def fillna( | |||
1 3.0 4.0 NaN 1 | |||
2 NaN 1.0 NaN 5 | |||
3 NaN 3.0 NaN 4 | |||
|
|||
Replacement happens along same column names and same indices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write this as "When filling using a DataFrame, replacement happens along the same column names and same indices:" (may need to split it across two lines). Other than that, looks good, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been updated, please take a look
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. @MarcoGorelli merge when satisfied
pandas/core/generic.py
Outdated
When filling using a DataFrame, replacement happens along | ||
the same column names and same indices | ||
|
||
>>> df2 = pd.DataFrame(np.zeros((5, 5)), columns=list("ABCED")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could df2
have columns "ABCE"
, so it's clear that there will be no replacement in column D (which is absent from df2
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
thanks @BEANNAN |
cc @MarcoGorelli