January 29, 2020

HISTOGRAM

  1. Group orders by customer_id and calculate the sum of price spent be each customer. Save the results to customer_amount.

    1. customer_amount = orders.groupby(‘customer_id’).price.sum( ).reset_index( )

  2. 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.

    1. plt.hist(customer_amount.price.values, range=(0, 200), bins = 40)

    2. plt.xlabel(‘Total Spent’)

    3. plt.ylabel(‘Number of Customers’)

    4. plt.title(‘Customer Expenditure Over 6 Months’)

    5. plt.show( )

Previous
Previous

February 7, 2020

Next
Next

January 28, 2020