-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: added examples for index assignment using Series #46064
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
Conversation
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. The failures are unrelated.
@@ -449,6 +449,38 @@ def loc(self) -> _LocIndexer: | |||
8 4 5 | |||
9 7 8 | |||
|
|||
**Set values with a Series** |
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.
this is ok but really not very idiomatic e.g. these should be on the __setitem__
doc-string e.g.
df['shield'] =
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.
Looks like this is the docstring of .loc
, that's why is using this idiom.
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.
sure but these are not idiomatic patterns for setting a column; sure if you have a mask then its the idimoatic way, but NOT for a column.
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.
Sorry, new contributor here. Where exactly should I be moving this documentation? Is it within this file (indexing.py)?
can you merge master |
@marco-georgaklis do you mind using a mask when columns are being set in this docstring so we don't show code that we wouldn't use in practice? Would be good if you can do it for the whole dosctring, not only your changes. Thanks! |
I'm not quite sure I understand. Should I be using a mask instead of .loc when the docstring is under the .loc property? |
Sorry I wasn't clear. The problem with your changes, is that in pandas we don't use: >>> df.loc[:, 'shield'] = pd.Series({7: 8, 8: 10, 9: 13}) Instead, we would use: >>> df['shield'] = pd.Series({7: 8, 8: 10, 9: 13}) The only case where we'd use >>> outstanding_employees = df['performance'] > 80
>>> df.loc[outstanding_employees, 'salary'] = ... So, if you can have a look at the docstring you're updating, check if it makes sense to have an example with a mask, and update it, so the |
Thanks for the pull request, but it appears to be stale. If interested in continuing, please merge in the main branch, address the review, and we can reopen. |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.