-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
REGR: Fixes first_valid_index when DataFrame or Series has duplicate row index (GH21441) #21497
Changes from 6 commits
6151181
003f801
952758a
1f4beb0
675201d
0640279
177a3f4
e94aad5
ff58ffd
d326b0a
b53bb11
0cb3405
11edb51
ed410e1
05e8a99
01a9f7e
cbcb089
111efb0
608c09e
d8fface
751046d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -612,6 +612,16 @@ def test_pct_change(self, periods, fill_method, limit, exp): | |
else: | ||
tm.assert_series_equal(res, Series(exp)) | ||
|
||
@pytest.mark.parametrize("data,index,expected_first,expected_last", [ | ||
({'A': [1, 2, 3]}, [1, 1, 2], 1, 2), | ||
({'A': [1, 2, 3]}, [1, 2, 2], 1, 2), | ||
({'A': [1, 2, 3, 4]}, ['d', 'd', 'd', 'd'], 'd', 'd')]) | ||
def test_valid_index(self, data, index, expected_first, expected_last): | ||
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. do we not already have some tests for this? pls put near the others. does this duplicate existing tests at all? 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.
Thanks - The only test involving |
||
# GH 21441 | ||
df = DataFrame(data, index=index) | ||
assert expected_first == df.first_valid_index() | ||
assert expected_last == df.last_valid_index() | ||
|
||
|
||
class TestNDFrame(object): | ||
# tests that don't fit elsewhere | ||
|
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.
what are you trying to do 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.
Thanks - this block is supposed to check that for multiple counts of same index, at least one is not NA.
However, while testing this with following data, the expected output is not being returned
Expected
1
, returnedNone
I'll rework this patch and commit again - Thanks again for the question prompt, it was fallacy of assumption on my part (had not checked explicitly for NaN value among the multiple index)
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.
the loop was incorrect leading to an error, not sure what I was thinking earlier :) - fixed now and committing
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.
Fixed - rebased and committed
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.
still not clear on the logic here, why can't this be a mirror of the 'last' logic?