Skip to content

Commit b196878

Browse files
Fix overflow error in cartesian_product
When the numbers in `X` are large it can cause an overflow error on windows machine where the native `int` is 32 bit. Switching to np.intp alleviates this problem. Other fixes would include switching to np.uint32 or np.uint64.
1 parent ead784f commit b196878

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pandas/tools/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def cartesian_product(X):
5555
if len(X) == 0:
5656
return []
5757

58-
lenX = np.fromiter((len(x) for x in X), dtype=int)
58+
lenX = np.fromiter((len(x) for x in X), dtype=np.intp)
5959
cumprodX = np.cumproduct(lenX)
6060

6161
a = np.roll(cumprodX, 1)

0 commit comments

Comments
 (0)