Skip to content
Permalink
92e72c3bf7
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
18 lines (13 sloc) 698 Bytes
import pandas as pd
class Binning:
def __init__(self, data):
self.rank_data = data.rank(method='first')
# todo (small reminder) in the original ipd it is NOT equal binning
# Series of binned points (with dropDuplicates produces not equally frequent bins)
def equal_frequency_binning(self, dim, bins_count):
return pd.qcut(self.rank_data.sort_values(by=dim)[dim], bins_count)
def equal_frequency_binning2(self, dim, bins_count):
qcut = pd.qcut(self.rank_data.sort_values(by=dim)[dim], bins_count)
return qcut.cat.rename_categories([i for i in range(bins_count)]).reindex(qcut.index)
def get_rank_data(self):
return self.rank_data