Skip to content
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

Fix loc for Series with a MultiIndex #7243

Merged
merged 24 commits into from
Jan 29, 2021

Conversation

shwina
Copy link
Contributor

@shwina shwina commented Jan 28, 2021

Fixes #7221 and adds improvements to loc with a MultiIndex.

  • Previously, loc on a Series with a MultiIndex would fail. For example:
In [7]: sr
Out[7]:
n_workers  type
1          fit        1
2          load       2
3          predict    3
Name: x, dtype: int64

In [8]: sr.loc[(1, "fit")]  # KeyError
  • Previously, loc on a DataFrame with a MultiIndex would fail when a slice without start or end was used. For example:
In [3]: df
Out[3]:
                   x
n_workers type
1         fit      1
2         load     2
3         predict  3

In [4]: df.loc[:(2, "load")]  # TypeError

Both the above issues have been addressed and tests added.

@shwina shwina requested a review from a team as a code owner January 28, 2021 17:04
@shwina shwina added non-breaking Non-breaking change bug Something isn't working labels Jan 28, 2021
@kkraus14 kkraus14 added the Python Affects Python cuDF API. label Jan 28, 2021
Copy link
Contributor

@isVoid isVoid left a comment

Choose a reason for hiding this comment

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

Perhaps PR description can provide a touch more detail on the improvement being made?

python/cudf/cudf/core/indexing.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@kkraus14 kkraus14 left a comment

Choose a reason for hiding this comment

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

LGTM but should address @rgsl888prabhu's comments

isVoid
isVoid approved these changes Jan 28, 2021
@codecov
Copy link

codecov bot commented Jan 28, 2021

Codecov Report

Merging #7243 (0b77b7a) into branch-0.18 (8860baf) will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.18    #7243      +/-   ##
===============================================
+ Coverage        82.09%   82.21%   +0.12%     
===============================================
  Files               97       99       +2     
  Lines            16474    16844     +370     
===============================================
+ Hits             13524    13849     +325     
- Misses            2950     2995      +45     
Impacted Files Coverage Δ
python/cudf/cudf/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/_fuzz_testing/parquet.py 0.00% <ø> (ø)
python/cudf/cudf/_lib/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/_typing.py 92.30% <ø> (ø)
python/cudf/cudf/core/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/core/abc.py 91.48% <ø> (+4.25%) ⬆️
python/cudf/cudf/core/buffer.py 80.00% <ø> (+0.95%) ⬆️
python/cudf/cudf/core/column/__init__.py 100.00% <ø> (ø)
python/cudf/cudf/core/column/categorical.py 92.73% <ø> (-0.62%) ⬇️
python/cudf/cudf/core/column/column.py 87.75% <ø> (-0.39%) ⬇️
... and 72 more

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 02166da...2416291. Read the comment docs.

@kkraus14
Copy link
Collaborator

@gpucibot merge

@kkraus14 kkraus14 added the 5 - Ready to Merge Testing and reviews complete, ready to merge label Jan 28, 2021
@shwina
Copy link
Contributor Author

shwina commented Jan 29, 2021

rerun tests

@kkraus14
Copy link
Collaborator

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 019d7cc into rapidsai:branch-0.18 Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] loc fails on a Series with a MultiIndex
5 participants