Skip to content

Commit 8967d3a

Browse files
uds5501victor
authored and
victor
committed
TST: adding test cases for verifying correct values shown by pivot_table() pandas-dev#21378 (pandas-dev#21393)
1 parent ffa4e03 commit 8967d3a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/reshape/test_pivot.py

+18
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ def test_pivot_with_non_observable_dropna(self, dropna):
161161

162162
tm.assert_frame_equal(result, expected)
163163

164+
# gh-21378
165+
df = pd.DataFrame(
166+
{'A': pd.Categorical(['left', 'low', 'high', 'low', 'high'],
167+
categories=['low', 'high', 'left'],
168+
ordered=True),
169+
'B': range(5)})
170+
171+
result = df.pivot_table(index='A', values='B', dropna=dropna)
172+
expected = pd.DataFrame(
173+
{'B': [2, 3, 0]},
174+
index=pd.Index(
175+
pd.Categorical.from_codes([0, 1, 2],
176+
categories=['low', 'high', 'left'],
177+
ordered=True),
178+
name='A'))
179+
180+
tm.assert_frame_equal(result, expected)
181+
164182
def test_pass_array(self):
165183
result = self.data.pivot_table(
166184
'D', index=self.data.A, columns=self.data.C)

0 commit comments

Comments
 (0)