Skip to content
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

Issue 21932: Added Regression Test for index of pivot_table on empty table #52809

Merged
merged 6 commits into from
Apr 22, 2023

Conversation

MirijaH
Copy link
Contributor

@MirijaH MirijaH commented Apr 20, 2023

@MirijaH MirijaH changed the title Issue 21932 Issue 21932: Added Regression Test for index of pivot_table on empty table Apr 20, 2023
@rhshadrach rhshadrach added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Needs Tests Unit test(s) needed to prevent regressions labels Apr 21, 2023
def test_pivot_table_empty_dataframe_correct_index(self):
# GH 21932
df = DataFrame([], columns=["a", "b", "value"])
pivot = df.pivot_table(index="a", columns="b", values="value",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run pre-commit? This is formatted incorrectly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for the head up, done :)

@phofl phofl added the Sprints Sprint Pull Requests label Apr 21, 2023
pivot = df.pivot_table(index="a", columns="b", values="value", aggfunc="count")

expected = pd.Index([], dtype="object", name="b")
tm.assert_index_equal(pivot.columns, expected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest you run pre-commit, please check the contributing guide for how to do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for the head up, done :)

@phofl phofl added this to the 2.1 milestone Apr 22, 2023
@phofl phofl merged commit c58fa84 into pandas-dev:main Apr 22, 2023
@phofl
Copy link
Member

phofl commented Apr 22, 2023

thx @MirijaH

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Tests Unit test(s) needed to prevent regressions Reshaping Concat, Merge/Join, Stack/Unstack, Explode Sprints Sprint Pull Requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pivot_table produces inconsistent columns if applied to empty table
4 participants