Solution Review: Exploring E-Commerce
This lesson provides solutions to the exercise on exploring E-Commerce Dataset in previous lesson.
1. Top customers with the highest number of orders
Press + to interact
import pandas as pddf = pd.read_csv('e_commerce.csv')# solutiontemp = 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 callsize
to retrieve the number of times eachCustomerID
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.