Skip to content

Commit e6c88c1

Browse files
anhqlesweb
authored andcommitted
TST add a test for pivot table large number of levels causing int32 overflow
1 parent da25b19 commit e6c88c1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/reshape/test_pivot.py

+8
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,14 @@ def test_pivot_string_func_vs_func(self, f, f_numpy):
12761276
aggfunc=f_numpy)
12771277
tm.assert_frame_equal(result, expected)
12781278

1279+
@pytest.mark.slow
1280+
def test_pivot_number_of_levels_larger_than_int32(self):
1281+
# GH 20601
1282+
data = DataFrame({'ind1': list(range(1337600)) * 2,
1283+
'ind2': list(range(3040)) * 2 * 440, 'count': [1] * 2 * 1337600})
1284+
with tm.assert_raises_regex(ValueError, 'int32 overflow'):
1285+
data.pivot_table(index='ind1', columns='ind2', values='count', aggfunc='count')
1286+
12791287

12801288
class TestCrosstab(object):
12811289

0 commit comments

Comments
 (0)