-
-
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
Conversation
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -584,6 +584,7 @@ Indexing | |||
- Bug in :meth:`DataFrame.loc` returned requested key plus missing values when ``loc`` was applied to single level from :class:`MultiIndex` (:issue:`27104`) | |||
- Bug in indexing on a :class:`Series` or :class:`DataFrame` with a :class:`CategoricalIndex` using a listlike indexer containing NA values (:issue:`37722`) | |||
- Bug in :meth:`DataFrame.xs` ignored ``droplevel=False`` for columns (:issue:`19056`) | |||
- Bug in :meth:`DataFrame.reindex` returns ``IndexingError`` for empty :class:`DataFrame` with ``tolerance`` not None or ``method="nearest"`` (:issue:`27315`) |
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
# 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, that helps me for the future. Moved the test
thanks @phofl |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Build on top of #27326