@@ -185,13 +185,6 @@ def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
185185 x , dtype = _coerce_to_type (x )
186186
187187 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-
195188 quantiles = np .linspace (0 , 1 , q + 1 )
196189 else :
197190 quantiles = q
@@ -208,17 +201,17 @@ def _bins_to_cuts(x, bins, right=True, labels=None,
208201 precision = 3 , include_lowest = False ,
209202 dtype = None , duplicates = 'raise' ):
210203
211- if duplicates not in ['raise' , 'drop' , 'allow' ]:
204+ if duplicates not in ['raise' , 'drop' ]:
212205 raise ValueError ("invalid value for 'duplicates' parameter, "
213206 "valid options are: raise, drop" )
214207
215208 unique_bins = algos .unique (bins )
216- if len (unique_bins ) < len (bins ):
209+ if len (unique_bins ) < len (bins ) and len ( bins ) != 2 :
217210 if duplicates == 'raise' :
218211 raise ValueError ("Bin edges must be unique: {}.\n You "
219212 "can drop duplicate edges by setting "
220213 "the 'duplicates' kwarg" .format (repr (bins )))
221- elif duplicates == 'drop' :
214+ else :
222215 bins = unique_bins
223216
224217 side = 'left' if right else 'right'
0 commit comments