Skip to content

DataFrame pivot_table nunique aggfunc test GH#29080 #52082

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 1 commit into from
Mar 24, 2023

Conversation

liang3zy22
Copy link
Contributor

"d": np.random.randint(0, 10, size=(10,)),
}
)
expected = test.pivot_table(
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 construct this without pivot_table i.e. expected = pd.DataFrame(..., columns=...)

@mroeschke mroeschke added Testing pandas testing functions or related to the test suite Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Mar 20, 2023
@liang3zy22 liang3zy22 force-pushed the gh29080 branch 3 times, most recently from bbcc62f to 0fbbbbd Compare March 21, 2023 12:31
"d": np.random.randint(0, 10, size=(10,)),
}
)
a = test["a"]
Copy link
Member

Choose a reason for hiding this comment

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

Actually to avoid all this, just make test non-random values e.g.

test = DataFrame({"a": range(10), ...)

nparr = np.full((10, 10), np.NaN)
expected = DataFrame(nparr, index=Index(range(10), name="a"), columns=columnval)
for i in range(10):
expected.loc[i, ("nunique", "c", i)] = float(1)
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 build these values in nparr?

@liang3zy22 liang3zy22 force-pushed the gh29080 branch 2 times, most recently from 6a44fa8 to 45ac820 Compare March 23, 2023 05:37
)

nparr = np.full((10, 10), np.NaN)
for i in range(10):
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @mroeschke . I know a new numpy function, and a new English word, :-).

@mroeschke mroeschke added this to the 2.1 milestone Mar 24, 2023
@mroeschke mroeschke merged commit b14dda9 into pandas-dev:main Mar 24, 2023
@mroeschke
Copy link
Member

Thanks @liang3zy22

@liang3zy22 liang3zy22 deleted the gh29080 branch March 24, 2023 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pandas pivot_table aggfunc/values parameters behaving oddly
2 participants