Skip to content

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

Merged
merged 4 commits into from
Nov 17, 2020

Conversation

phofl
Copy link
Member

@phofl phofl commented Nov 15, 2020

Build on top of #27326

@phofl phofl added the Indexing Related to indexing on series/frames, not to indexes themselves label Nov 15, 2020
@@ -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`)
Copy link
Member

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

Copy link
Member Author

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)
Copy link
Member

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

Copy link
Member Author

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

@jreback jreback added this to the 1.2 milestone Nov 17, 2020
@jreback jreback merged commit 4c6feae into pandas-dev:master Nov 17, 2020
@jreback
Copy link
Contributor

jreback commented Nov 17, 2020

thanks @phofl

@phofl phofl deleted the 27315 branch November 17, 2020 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

some argument combinations with reindex fails on an empty dataframe
3 participants