def percentiles(a, pcts, axis=None):
 scores = []
 try:
  n = len(pcts)
 except TypeError:
  pcts = [pcts]
  n = 0
 for (i, p) in enumerate(pcts):
  if (axis is None):
   score = stats.scoreatpercentile(a.ravel(), p)
  else:
   score = np.apply_along_axis(stats.scoreatpercentile, axis, a, p)
  scores.append(score)
 scores = np.asarray(scores)
 if (not n):
  scores = scores.squeeze()
 return scores

def percentiles ( a , pcts , axis = None ) : scores = [ ] try : n = len ( pcts ) except TypeError : pcts = [ pcts ] n = 0 for ( i , p ) in enumerate ( pcts ) : if ( axis is None ) : score = stats . scoreatpercentile ( a . ravel ( ) , p ) else : score = np . apply_along_axis ( stats . scoreatpercentile , axis , a , p ) scores . append ( score ) scores = np . asarray ( scores ) if ( not n ) : scores = scores . squeeze ( ) return scores
like scoreatpercentile but can take and return array of percentiles .