Skip to content

Commit 1bb2f60

Browse files
committed
BUG: cut/qcut should always return int64 bins
closes pandas-dev#14866
1 parent 1e753d7 commit 1bb2f60

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/tests/tools/test_tile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class TestCut(tm.TestCase):
1919
def test_simple(self):
2020
data = np.ones(5)
2121
result = cut(data, 4, labels=False)
22-
desired = np.array([1, 1, 1, 1, 1])
23-
tm.assert_numpy_array_equal(result, desired,
22+
expected = np.array([1, 1, 1, 1, 1])
23+
tm.assert_numpy_array_equal(result, expected,
2424
check_dtype=False)
2525

2626
def test_bins(self):

pandas/tools/tile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from pandas.types.missing import isnull
66
from pandas.types.common import (is_float, is_integer,
7-
is_scalar)
7+
is_scalar, _ensure_int64)
88

99
from pandas.core.api import Series
1010
from pandas.core.categorical import Categorical
@@ -215,7 +215,7 @@ def _bins_to_cuts(x, bins, right=True, labels=None,
215215
bins = unique_bins
216216

217217
side = 'left' if right else 'right'
218-
ids = bins.searchsorted(x, side=side)
218+
ids = _ensure_int64(bins.searchsorted(x, side=side))
219219

220220
if include_lowest:
221221
ids[x == bins[0]] = 1

0 commit comments

Comments
 (0)