@@ -83,6 +83,7 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
83
83
"""
84
84
# NOTE: this binning code is changed a bit from histogram for var(x) == 0
85
85
# for handling the cut for datetime and timedelta objects
86
+ x_is_series , series_index , name , x = _preprocess_for_cut (x )
86
87
87
88
original , x , dtype = _coerce_to_type (x )
88
89
@@ -119,8 +120,6 @@ def cut(x, bins, right=True, labels=None, retbins=False, precision=3,
119
120
if (np .diff (bins ) < 0 ).any ():
120
121
raise ValueError ('bins must increase monotonically.' )
121
122
122
- x_is_series , series_index , name , x = _preprocess_for_cut (x )
123
-
124
123
fac , bins = _bins_to_cuts (x , bins , right = right , labels = labels ,
125
124
retbins = retbins , precision = precision ,
126
125
include_lowest = include_lowest , dtype = dtype )
@@ -176,10 +175,10 @@ def qcut(x, q, labels=None, retbins=False, precision=3):
176
175
>>> pd.qcut(range(5), 4, labels=False)
177
176
array([0, 0, 1, 2, 3], dtype=int64)
178
177
"""
179
- original , x , dtype = _coerce_to_type (x )
180
-
181
178
x_is_series , series_index , name , x = _preprocess_for_cut (x )
182
179
180
+ original , x , dtype = _coerce_to_type (x )
181
+
183
182
if is_integer (q ):
184
183
quantiles = np .linspace (0 , 1 , q + 1 )
185
184
else :
0 commit comments