How to add previous date infront of every unique customer id's invoice date - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to add previous date infront of every unique customer id's invoice date (/thread-32388.html) |
How to add previous date infront of every unique customer id's invoice date - ur_enegmatic - Feb-06-2021 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 RE: How to add previous date infront of every unique customer id's invoice date - eddywinch82 - Feb-06-2021 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 |