@@ -185,13 +185,6 @@ def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
185
185
x , dtype = _coerce_to_type (x )
186
186
187
187
if is_integer (q ):
188
- if x .size == 0 :
189
- raise ValueError ('Cannot qcut empty array' )
190
-
191
- rng = (nanops .nanmin (x ), nanops .nanmax (x ))
192
- if rng [0 ] == rng [1 ] and q == 1 :
193
- duplicates = 'allow'
194
-
195
188
quantiles = np .linspace (0 , 1 , q + 1 )
196
189
else :
197
190
quantiles = q
@@ -208,17 +201,17 @@ def _bins_to_cuts(x, bins, right=True, labels=None,
208
201
precision = 3 , include_lowest = False ,
209
202
dtype = None , duplicates = 'raise' ):
210
203
211
- if duplicates not in ['raise' , 'drop' , 'allow' ]:
204
+ if duplicates not in ['raise' , 'drop' ]:
212
205
raise ValueError ("invalid value for 'duplicates' parameter, "
213
206
"valid options are: raise, drop" )
214
207
215
208
unique_bins = algos .unique (bins )
216
- if len (unique_bins ) < len (bins ):
209
+ if len (unique_bins ) < len (bins ) and len ( bins ) != 2 :
217
210
if duplicates == 'raise' :
218
211
raise ValueError ("Bin edges must be unique: {}.\n You "
219
212
"can drop duplicate edges by setting "
220
213
"the 'duplicates' kwarg" .format (repr (bins )))
221
- elif duplicates == 'drop' :
214
+ else :
222
215
bins = unique_bins
223
216
224
217
side = 'left' if right else 'right'
0 commit comments