Python Forum
How to add previous date infront of every unique customer id's invoice date
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add previous date infront of every unique customer id's invoice date
#1
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
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.
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Print Report Invoice nio74maz 0 282 Jun-17-2021, 08:25 AM
Last Post: nio74maz
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 476 May-04-2021, 10:51 PM
Last Post: rhat398
  IF statement to apply at each date illmattic 2 912 Apr-08-2021, 12:31 PM
Last Post: illmattic
  String to Date format SAF 2 689 Apr-06-2021, 02:09 PM
Last Post: snippsat
  Naming the file as time and date. BettyTurnips 3 752 Jan-15-2021, 07:52 AM
Last Post: BettyTurnips
  Update Date based on Time/String stevezemlicka 1 580 Jan-08-2021, 06:54 PM
Last Post: Gribouillis
  Formatting date in a dataframe WiPi 1 447 Jan-06-2021, 11:26 AM
Last Post: WiPi
  Confusion about [date]time [formatting] Mark17 0 583 Dec-17-2020, 07:25 PM
Last Post: Mark17
  Examples of Customer requirements ComputerAstronaut 1 594 Dec-08-2020, 03:22 AM
Last Post: Larz60+
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 562 Dec-06-2020, 04:14 PM
Last Post: Divya577

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020