-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Test pivot_table() with categorical data #28803
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
TST: Test pivot_table() with categorical data #28803
Conversation
44d09f9
to
3d485d2
Compare
@jorisvandenbossche @jschendel Just had a go at this - let me know if any changes required |
pandas/tests/reshape/test_pivot.py
Outdated
@@ -2554,3 +2554,38 @@ def test_margin_normalize(self): | |||
names=["A", "B"], | |||
) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_pivot_with_categorical(self): | |||
# gh-21370 |
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.
can you move this near def test_categorical_margins_category(self, observed)
also if you can accept the observed fixture.
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.
Done
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.
Can you also use the ordered_fixture
instead of using ordered=True
.
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.
@topper-123 thanks, just added and pushed latest changes
8495a98
to
f19e1bf
Compare
Don't know why CI is failing - not sure error is related to my PR
|
…st-PivotTable-Categoricaldata
@@ -1656,6 +1656,49 @@ def test_categorical_margins_category(self, observed): | |||
table = df.pivot_table("x", "y", "z", dropna=observed, margins=True) | |||
tm.assert_frame_equal(table, expected) | |||
|
|||
def test_pivot_with_categorical(self, observed, ordered_fixture): | |||
# gh-21370 | |||
idx = [np.nan, "low", "high", "low", np.nan] |
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 are not using observed here?
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.
@jreback Do you mean pass as keyword arg to pivot_table()
? Ive just pushed changes
thanks @ryankarlos |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff