...

/

Solution Review: Exploring E-Commerce

Solution Review: Exploring E-Commerce

This lesson provides solutions to the exercise on exploring E-Commerce Dataset in previous lesson.

1. Top 55 customers with the highest number of orders

Press + to interact
import pandas as pd
df = pd.read_csv('e_commerce.csv')
# solution
temp = df.groupby('CustomerID').size()
temp = temp.sort_values(ascending=False)
temp = temp.iloc[:5]
print(temp)

We do this task in three steps:

  • First, we group our data with CustomerID and call size to retrieve the number of times each CustomerID appeared in the data in line 5.
  • Second, we sort the values in descending order using sort_values in
...
Access this course and 1400+ top-rated courses and projects.