Skip to content

Conversation

@jreback
Copy link
Contributor

@jreback jreback commented Oct 6, 2017

closes #17740

@jreback jreback added Docs Indexing Related to indexing on series/frames, not to indexes themselves labels Oct 6, 2017
@jreback jreback added this to the 0.21.0 milestone Oct 6, 2017
@jreback
Copy link
Contributor Author

jreback commented Oct 6, 2017

@codecov
Copy link

codecov bot commented Oct 6, 2017

Codecov Report

Merging #17803 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@ ## master #17803 +/- ## ========================================== - Coverage 91.24% 91.22% -0.02%  ========================================== Files 163 163 Lines 49971 49971 ========================================== - Hits 45597 45588 -9  - Misses 4374 4383 +9
Flag Coverage Δ
#multiple 89.03% <ø> (ø) ⬆️
#single 40.24% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5653fe4...248830b. Read the comment docs.

@codecov
Copy link

codecov bot commented Oct 6, 2017

Codecov Report

Merging #17803 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@ ## master #17803 +/- ## ========================================== - Coverage 91.25% 91.23% -0.03%  ========================================== Files 163 163 Lines 49971 49971 ========================================== - Hits 45599 45589 -10  - Misses 4372 4382 +10
Flag Coverage Δ
#multiple 89.03% <ø> (-0.01%) ⬇️
#single 40.24% <ø> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.74% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.48% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b4121b...e0ebb7e. Read the comment docs.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks!

I would also add that previously for non-boolean and non-numeric indices, it would raise a KeyError (since the True / False were regarded as labels), and not will do boolean selection.

@jreback
Copy link
Contributor Author

jreback commented Oct 6, 2017

Iwould also add that previously for non-boolean and non-numeric indices, it would raise a KeyError (since the True / False were regarded as labels), and not will do boolean selection.

not following, what is the example?

@jorisvandenbossche
Copy link
Member

So previously Index with True / False values were always regarded as labels, not as a boolean mask. Which resulted in a KeyError for non-numeric indices or actual label-based indexing for numeric/boolean index (the fact that it interpreted True/False as 1/0 is the bug that was been fixed in an earlier PR regarding drop, but the general thing (your recent PR) that boolean index is not seen as labels is the API change you describe in the PR here).

So previous:

In [38]: s = pd.Series([1,2,3], index=['a', 'b', 'c']) In [39]: s.loc[pd.Index([True, False, True])] ... KeyError: "None of [Index([True, False, True], dtype='object')] are in the [index]" In [42]: s = pd.Series([1,2,3]) In [43]: s.loc[pd.Index([True, False, True])] Out[43]: 1 2 0 1 1 2 dtype: int64 

Now:

In [4]: s = pd.Series([1,2,3], index=['a', 'b', 'c']) In [5]: s.loc[pd.Index([True, False, True])] Out[5]: a 1 c 3 dtype: int64 In [6]: s = pd.Series([1,2,3]) In [7]: s.loc[pd.Index([True, False, True])] Out[7]: 0 1 2 3 dtype: int64 
@jorisvandenbossche
Copy link
Member

(but it is not perse necessary to add all those example, for me just adding it in the text is fine as well. I suspect that not many people deliberately will have used a boolean index to index a non-numeric index and explicitly catched the KeyError ... The main change is when you actually had a boolean index in the object you are indexing (i.e. the case for which you already have an example))

@jreback
Copy link
Contributor Author

jreback commented Oct 6, 2017

ic, ok will add that as well.

@jreback jreback merged commit 1335090 into pandas-dev:master Oct 6, 2017
ghost pushed a commit to reef-technologies/pandas that referenced this pull request Oct 16, 2017
alanbato pushed a commit to alanbato/pandas that referenced this pull request Nov 10, 2017
No-Stream pushed a commit to No-Stream/pandas that referenced this pull request Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Indexing Related to indexing on series/frames, not to indexes themselves

2 participants