Skip to content

Commit da25b19

Browse files
anhqlesweb
authored andcommitted
ENH GH20601 raise an error when the number of levels in a pivot table larger than int32
1 parent 0d6cb3c commit da25b19

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/reshape/reshape.py

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def _make_selectors(self):
162162
self.full_shape = ngroups, stride
163163

164164
selector = self.sorted_labels[-1] + stride * comp_index + self.lift
165+
if np.prod(self.full_shape) > (2 ** 31 - 1):
166+
raise ValueError('Pivot table is too big, causing int32 overflow')
165167
mask = np.zeros(np.prod(self.full_shape), dtype=bool)
166168
mask.put(selector, True)
167169

0 commit comments

Comments
 (0)