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
  Compare current date on calendar with date format file name Fioravanti 1 123 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Date Time Series Help...Please spra8560 2 313 Feb-01-2024, 01:38 PM
Last Post: spra8560
  Create dual folder on different path/drive based on the date agmoraojr 2 378 Jan-21-2024, 10:02 AM
Last Post: snippsat
  Python date format changes to date & time 1418 4 518 Jan-20-2024, 04:45 AM
Last Post: 1418
  Downloading time zone aware files, getting wrong files(by date))s tester_V 9 961 Jul-23-2023, 08:32 AM
Last Post: deanhystad
  Formatting a date time string read from a csv file DosAtPython 5 1,161 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  PDF properties doesn't show created or modified date Pedroski55 4 1,007 Jun-19-2023, 08:09 AM
Last Post: Pedroski55
  How should I run pip-date in python3? newbieAuggie2019 5 1,775 Mar-31-2023, 03:21 PM
Last Post: snippsat
  How to see the date of installation of python modules. newbieAuggie2019 4 1,466 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 1,912 Dec-17-2022, 12:24 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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