def qcut(x, q, labels=None, retbins=False, precision=3, duplicates='raise'):
 (x_is_series, series_index, name, x) = _preprocess_for_cut(x)
 (x, dtype) = _coerce_to_type(x)
 if is_integer(q):
  quantiles = np.linspace(0, 1, (q + 1))
 else:
  quantiles = q
 bins = algos.quantile(x, quantiles)
 (fac, bins) = _bins_to_cuts(x, bins, labels=labels, precision=precision, include_lowest=True, dtype=dtype, duplicates=duplicates)
 return _postprocess_for_cut(fac, bins, retbins, x_is_series, series_index, name)

def qcut ( x , q , labels = None , retbins = False , precision = 3 , duplicates = 'raise' ) : ( x_is_series , series_index , name , x ) = _preprocess_for_cut ( x ) ( x , dtype ) = _coerce_to_type ( x ) if is_integer ( q ) : quantiles = np . linspace ( 0 , 1 , ( q + 1 ) ) else : quantiles = q bins = algos . quantile ( x , quantiles ) ( fac , bins ) = _bins_to_cuts ( x , bins , labels = labels , precision = precision , include_lowest = True , dtype = dtype , duplicates = duplicates ) return _postprocess_for_cut ( fac , bins , retbins , x_is_series , series_index , name )
quantile-based discretization function .