-
-
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 2 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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,13 +649,6 @@ def test_asfreq_fill_value(self): | |
expected = frame.reindex(new_index, fill_value=4.0) | ||
assert_frame_equal(result, expected) | ||
|
||
def test_resample_interpolate(self): | ||
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. Removed this test as it was failing - investigated and seems that this test is from a closed PR #12974 opened for issue #12925 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. Restored this test now - this test along with others were failing due to error in interpolation, which is fixed now |
||
# # 12925 | ||
df = self.create_series().to_frame('value') | ||
assert_frame_equal( | ||
df.resample('1T').asfreq().interpolate(), | ||
df.resample('1T').interpolate()) | ||
|
||
def test_raises_on_non_datetimelike_index(self): | ||
# this is a non datetimelike index | ||
xp = DataFrame() | ||
|
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.
I don't think the :meth: will correctly link to anything as written since there's no global
pd.first_valid_index
. You can write something like "Bug in both :meth:`Series.first_valid_index` and :meth:`DataFrame.first_valid_index` ..." if you want to be explicit that both are affected, which would link to bothSeries
andDataFrame
separately.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 - Done