Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##########################################
- # each bin is equally filled and cut based on quantiles
- def qcut(array, number_of_bins):
- import pandas as pd
- from scipy import stats
- bins = stats.mstats.mquantiles(array, [i/number_of_bins for i in range(number_of_bins+1)])
- labels = list(range(number_of_bins))
- return pd.cut(array, bins, labels = labels).fillna(0)
Add Comment
Please, Sign In to add comment