I have a data set of all customers purchases made in the last 5 years with the below columns as an example.
CUSTOMER ID | ORDER NUMBER | ORDER DATE (DateTime) | ITEM ID
What I need to do is assign each individual customer order position (i.e 1,2,3,4) - So for each customer I am able to know which order was their 1st 2nd or 3rd using the above criteria
Things to consider:
- There are multiple Customer ID's and Order Numbers in the same table
- There are multiple rows from the same customer & order number combination as each order has multiple items, so if the first order for a customer has 3 items on it I want all 3 items to show as 1.
Struggling to find a starting point of how to do this
Below is the data table:
import pandas as pd
df = pd.DataFrame({'Customer ID' : ['C100003','C100002','C100002','C100002','C100003','C100002'],
'Order Number' : ['RJSJ0053','RJSJ0060','RJSJ0085','RJSJ0085','RJSJ0089','RJSJ0092'],
'Order Date' : ['2023-05-08','2023-06-09','2023-06-13','2023-06-13','2023-06-13','2023-06-14'],
'Item ID' : ['Mouse','Keyboard','Computer','Monitor','Keyboard','Headset'],
'Order Position' : [1,1,2,2,2,3]})