Skip to content

Commit 7f22bb4

Browse files
committed
moving preprocess prior to coerce to type
1 parent 04437c3 commit 7f22bb4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pandas/tools/tile.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
8383
"""
8484
# NOTE: this binning code is changed a bit from histogram for var(x) == 0
8585
# for handling the cut for datetime and timedelta objects
86+
x_is_series, series_index, name, x = _preprocess_for_cut(x)
8687

8788
original, x, dtype = _coerce_to_type(x)
8889

@@ -119,8 +120,6 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
119120
if (np.diff(bins) < 0).any():
120121
raise ValueError('bins must increase monotonically.')
121122

122-
x_is_series, series_index, name, x = _preprocess_for_cut(x)
123-
124123
fac, bins = _bins_to_cuts(x, bins, right=right, labels=labels,
125124
retbins=retbins, precision=precision,
126125
include_lowest=include_lowest, dtype=dtype)
@@ -176,10 +175,10 @@ def qcut(x, q, labels=None, retbins=False, precision=3):
176175
>>> pd.qcut(range(5), 4, labels=False)
177176
array([0, 0, 1, 2, 3], dtype=int64)
178177
"""
179-
original, x, dtype = _coerce_to_type(x)
180-
181178
x_is_series, series_index, name, x = _preprocess_for_cut(x)
182179

180+
original, x, dtype = _coerce_to_type(x)
181+
183182
if is_integer(q):
184183
quantiles = np.linspace(0, 1, q + 1)
185184
else:

0 commit comments

Comments
 (0)