Creating a Frequency Table from a Dataframe Column

Python

 1|  #Counts for each value in order_value column 
 2|  df['order_value'].value_counts()
 3|  
 4|  #Counts aggregated into 5 bins
 5|  df['order_value'].value_counts(bins=5)
 6|  
 7|  #Counts aggregated into 5 bins and sorted by order_value bin
 8|  df['order_value'].value_counts(bins=5).sort_index()
Did you find this snippet useful?

Sign up for free to to add this to your code library