-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix multiindex loc nan #43943
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
Closed
Closed
Fix multiindex loc nan #43943
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
549386c
fix problem without adding tests
CloseChoice 81970c7
add test, still not all tests running
CloseChoice 8443c62
remove print and debug statements
CloseChoice 9eae773
Fixes from pre-commit [automated commit]
CloseChoice c497e34
add new test
CloseChoice fde027b
update test as desired in PR comments
CloseChoice 0ef5d04
Merge branch 'FIX-multiindex-loc-nan' of github.com:CloseChoice/panda…
CloseChoice 246a421
add whatsnew entry
CloseChoice bbeeb1b
fix wrong issue number
CloseChoice 6b38ba4
save nan encoding in new state variable and replace it before returni…
CloseChoice d04b7b8
remove wrong whatsnew entry
CloseChoice cc75b44
remove debug statement
CloseChoice c88b2d8
add whatsnew entry
CloseChoice 0a3ce38
Merge branch 'FIX-multiindex-loc-nan' of github.com:CloseChoice/panda…
CloseChoice ed537cc
Merge branch 'master' into FIX-multiindex-loc-nan
CloseChoice 77e7283
fix wrong code quotes in whatsnew
CloseChoice 72fb026
WIP: add support for (pd.NA, pd.NaT, np.datetime64("NaT", "ns"), np.t…
CloseChoice cf0355d
WIP: add support for (pd.NA, pd.NaT, np.datetime64("NaT", "ns"), np.t…
CloseChoice 427a515
Fixes from pre-commit [automated commit]
CloseChoice 29c37b6
fix problem without adding tests
CloseChoice d274bca
add test, still not all tests running
CloseChoice f72cbf7
remove print and debug statements
CloseChoice 7ab0c9c
Fixes from pre-commit [automated commit]
CloseChoice a758d44
add new test
CloseChoice c3ec7f0
update test as desired in PR comments
CloseChoice 245b141
add whatsnew entry
CloseChoice ae706c8
fix wrong issue number
CloseChoice 30097ca
save nan encoding in new state variable and replace it before returni…
CloseChoice ef951a6
remove wrong whatsnew entry
CloseChoice 0fa1784
remove debug statement
CloseChoice 1f78023
add whatsnew entry
CloseChoice 5b3c61d
fix wrong code quotes in whatsnew
CloseChoice 98c8f13
WIP: add support for (pd.NA, pd.NaT, np.datetime64("NaT", "ns"), np.t…
CloseChoice ec218d5
WIP: add support for (pd.NA, pd.NaT, np.datetime64("NaT", "ns"), np.t…
CloseChoice d92cc60
Merge branch 'master' into FIX-multiindex-loc-nan
CloseChoice 4dda020
Merge branch 'FIX-multiindex-loc-nan' of github.com:CloseChoice/panda…
CloseChoice 6850b73
add tests for issue 36060
CloseChoice e7a52e3
Fixes from pre-commit [automated commit]
CloseChoice 9682350
changes according to PR discussions
CloseChoice 0ad2583
Merge branch 'FIX-multiindex-loc-nan' of github.com:CloseChoice/panda…
CloseChoice cb92f95
use assert_series_equal in test_groupby_dropna
CloseChoice e3c734d
make _has_na_placeholder cache_readonly
CloseChoice cf48e70
make _has_na_placeholder cache_readonly
CloseChoice 49b1d65
Fixes from pre-commit [automated commit]
CloseChoice d00b39f
remove commented out stuff
CloseChoice a97ef1a
Merge branch 'FIX-multiindex-loc-nan' of github.com:CloseChoice/panda…
CloseChoice d180901
remove unnecessary import
CloseChoice cc6af9d
WIP: intermediate commit for loop solution
CloseChoice 02bf699
changes for static analysis checks
CloseChoice 7211984
Merge branch 'master' of github.com:pandas-dev/pandas into FIX-multii…
CloseChoice 4520444
fix imports
CloseChoice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,3 +392,18 @@ def test_loc_empty_multiindex(): | |
result = df | ||
expected = DataFrame([1, 2, 3, 4], index=index, columns=["value"]) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
def test_loc_nan_multiindex(): | ||
df = DataFrame( | ||
{ | ||
"temp_playlist": [0, 0, 0, 0], | ||
"objId": ["o1", np.nan, "o1", np.nan], | ||
"x": [1, 2, 3, 4], | ||
} | ||
) | ||
|
||
agg_df = df.groupby(by=["temp_playlist", "objId"], dropna=False)["x"].agg(list) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you parameterize on dropna=True & False |
||
result = agg_df.loc[agg_df.index[-1]] | ||
expected = [2, 4] | ||
assert result == expected |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 add the issue number as a comment here
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.
since we are declaring this a regression, we should maybe have a test that previously passed. In what previous version of pandas did this test pass?