January 29, 2020
HISTOGRAM
Group orders by customer_id and calculate the sum of price spent be each customer. Save the results to customer_amount.
customer_amount = orders.groupby(‘customer_id’).price.sum( ).reset_index( )
Create a histogram of this data. Range should be 0 to 200. Number of bins should be 40. Label x-axis as Total Spent. Label y-axis as Number of Customers. Add a title.
plt.hist(customer_amount.price.values, range=(0, 200), bins = 40)
plt.xlabel(‘Total Spent’)
plt.ylabel(‘Number of Customers’)
plt.title(‘Customer Expenditure Over 6 Months’)
plt.show( )