Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

bucket dataframe into ranges

def conditions(i): 
    if i <=50: return '0-50'
    if i > 50 and i <=100: return '50-100'
    if i > 100 and i <=250: return '100-250'
    if i > 250 and i <=350: return '250-350'
    if i > 350: return '>350'

df['C']=df['B'].apply(conditions)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #bucket #dataframe #ranges
ADD COMMENT
Topic
Name
1+8 =