-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG in reindex raises IndexingError when df is empty sometimes #37874
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
Changes from 3 commits
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
from pandas import NA, DataFrame, Index, date_range | ||
import pandas._testing as tm | ||
|
||
|
||
class TestReindex: | ||
@pytest.mark.parametrize( | ||
"kwargs", | ||
[ | ||
{"method": "pad", "tolerance": timedelta(seconds=9)}, | ||
{"method": "backfill", "tolerance": timedelta(seconds=9)}, | ||
{"method": "nearest"}, | ||
{"method": None}, | ||
], | ||
) | ||
def test_reindex_empty_frame(self, kwargs): | ||
# GH#27315 | ||
idx = date_range(start="2020", freq="30s", periods=3) | ||
df = DataFrame([], index=Index([], name="time"), columns=["a"]) | ||
result = df.reindex(idx, **kwargs) | ||
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. you're testing the DataFrame.reindex method, this goes in tests.frame.methods.test_reindex rule of thumb: if you need Series or DataFrame, it probably doesnt belong in tests.indexes 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. Thx, that helps me for the future. Moved the test |
||
expected = DataFrame({"a": [NA] * 3}, index=idx) | ||
tm.assert_frame_equal(result, expected) |
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.
is the bug that it is raising IndexingError when it shouldnt or that it isnt when it should?
returns -> raising
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.
wrongly raising when it should not. Changed and clarified it