Skip to content

Added alignable boolean series and its example to .loc docs. #35506

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

Merged

Conversation

MJafarMashhadi
Copy link
Contributor

@MJafarMashhadi MJafarMashhadi commented Aug 1, 2020

I'm just not sure if I needed to add IndexingError to raises section. Added it to be safe, will remove if it's unnecessary.

Also, when someone uses df.loc[df['col'] > 0] it really is the same under the hood, df['col'] > 0 is a boolean series with an alignable index. So there might be some overlap?

Copy link
Member

@arw2019 arw2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @MJafarMashhadi

A few small comments. Otherwise lgtm

@@ -255,6 +255,8 @@ def loc(self) -> "_LocIndexer":

- A boolean array of the same length as the axis being sliced,
e.g. ``[True, False, True]``.
- An alignable boolean series. Index of the key will be aligned before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

series should be capitalized

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: 'The index of the key'

@@ -264,6 +266,8 @@ def loc(self) -> "_LocIndexer":
------
KeyError
If any items are not found.
IndexingError
If an indexed key is passed and its index is unalignable to the index.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: 'unalignable to the frame index'

@@ -319,6 +323,13 @@ def loc(self) -> "_LocIndexer":
max_speed shield
sidewinder 7 8

Alignable boolean series:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

series should be capitalized

Copy link
Member

@arw2019 arw2019 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great

@MJafarMashhadi
Copy link
Contributor Author

Thanks for the review!

@simonjayhawkins simonjayhawkins added this to the 1.2 milestone Aug 2, 2020
@simonjayhawkins simonjayhawkins merged commit a0c8425 into pandas-dev:master Aug 2, 2020
@simonjayhawkins
Copy link
Member

Thanks @MJafarMashhadi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: intended series.loc behavior undocumented for boolean series
3 participants