def bucket(series, k, by=None):
 if (by is None):
  by = series
 else:
  by = by.reindex(series.index)
 split = _split_quantile(by, k)
 mat = (np.empty((len(series), k), dtype=float) * np.NaN)
 for (i, v) in enumerate(split):
  mat[:, i][v] = series.take(v)
 return DataFrame(mat, index=series.index, columns=(np.arange(k) + 1))

def bucket ( series , k , by = None ) : if ( by is None ) : by = series else : by = by . reindex ( series . index ) split = _split_quantile ( by , k ) mat = ( np . empty ( ( len ( series ) , k ) , dtype = float ) * np . NaN ) for ( i , v ) in enumerate ( split ) : mat [ : , i ] [ v ] = series . take ( v ) return DataFrame ( mat , index = series . index , columns = ( np . arange ( k ) + 1 ) )
produce dataframe representing quantiles of a series parameters series : series k : int number of quantiles by : series or same-length array bucket by value returns dataframe .