def percentiles_summary(df, num_old, num_new, upsample, state):
 from dask.array.percentile import _percentile
 length = len(df)
 if (length == 0):
  return ()
 random_state = np.random.RandomState(state)
 qs = sample_percentiles(num_old, num_new, length, upsample, random_state)
 data = df.values
 interpolation = 'linear'
 if (str(data.dtype) == 'category'):
  data = data.codes
  interpolation = 'nearest'
 vals = _percentile(data, qs, interpolation=interpolation)
 if ((interpolation == 'linear') and np.issubdtype(data.dtype, np.integer)):
  vals = np.round(vals).astype(data.dtype)
 vals_and_weights = percentiles_to_weights(qs, vals, length)
 return vals_and_weights

def percentiles_summary ( df , num_old , num_new , upsample , state ) : from dask . array . percentile import _percentile length = len ( df ) if ( length == 0 ) : return ( ) random_state = np . random . RandomState ( state ) qs = sample_percentiles ( num_old , num_new , length , upsample , random_state ) data = df . values interpolation = 'linear' if ( str ( data . dtype ) == 'category' ) : data = data . codes interpolation = 'nearest' vals = _percentile ( data , qs , interpolation = interpolation ) if ( ( interpolation == 'linear' ) and np . issubdtype ( data . dtype , np . integer ) ) : vals = np . round ( vals ) . astype ( data . dtype ) vals_and_weights = percentiles_to_weights ( qs , vals , length ) return vals_and_weights
summarize data using percentiles and derived weights .