Im trying to add a previous date cloumn in my current df where every infornt of every unique cust_id i ndeed to populate the previous date based on invoice date. There are only 2 columns Customer Id and Date and both are str type. The problem is I'm getting a blank dataframe. the code is running fine and doesn't give any error output.. Am I doing something wrong here?
Customer ID Date previous_date
inter_data=pd.DataFrame() for cust in customers: cust_dt= customer_group[customer_group['Customer ID']=='cust'] cust_dt['previous_date']=cust_dt['Date'].shift(1) inter_data=pd.concat([inter_data,cust_dt], axis=0)OUTPUT data frame, with no values updated
Customer ID Date previous_date
buran write Feb-06-2021, 07:49 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.