Tutorial by Examples

First, Lets create a dummy dataframe We assume that a customer can have n orders, an order can have m items, and items can be ordered more multiple times orders_df = pd.DataFrame() orders_df['customer_id'] = [1,1,1,1,1,2,2,3,3,3,3,3] orders_df['order_id'] = [1,1,1,2,2,3,3,4,5,6,6,6] orders_df['...
Using transform functions that return sub-calculations per group In the previous example, we had one result per client. However, functions returning different values for the group can also be applied. # Create a dummy dataframe orders_df = pd.DataFrame() orders_df['customer_id'] = [1,1,1,1,1,2,...

Page 1 of 1