top of page
import pandas as pd
data = [[1, 1], [2, 2], [3, 3], [4, 3]]
orders = pd.DataFrame(data, columns=['order_number', 'customer_number']).astype({'order_number':'Int64', 'customer_number':'Int64'})
def largest_orders(orders: pd.DataFrame) -> pd.DataFrame:
grouped = orders.groupby('customer_number').count().reset_index()
sort = orders.sort_values(by='order_number', ascending= False).head(1)
sort = sort[["customer_number"]]
return sort
result = largest_orders(orders)
print(result)
#OR
def largest_orders(orders: pd.DataFrame) -> pd.DataFrame:
return orders['customer_number'].mode().to_frame()
result = largest_orders(orders)
print(result)
bottom of page