Python Forum

Full Version: How to add previous date infront of every unique customer id's invoice date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?

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
Hi ur_enegmatic,

Could you post the entire Python Code, and the File you are using ? And I will try to come up, with a solution for you tommorrow.

Best Regards

Eddie Winch