Python Forum
Finding date count from a list of date range in pandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Finding date count from a list of date range in pandas
#1
I have the pandas df in the following format (with NoOFDays being EndDate - StartDate)

------------------------------------------
|Item | StartDate | EndDate | NoOFDays|
------------------------------------------
| A | 01-Jan-2018| 04-Jan-2018| 4 |
| A | 07-Jan-2018| 08-Jan-2018| 2 |
| B | 03-Jan-2018| 05-Jan-2018| 3 |
| A | 03-Jan-2018| 05-Jan-2018| 3 |
------------------------------------------

And wanted to get the count of each day grouped by item

A 01-Jan-2018 1
A 02-Jan-2018 1
A 03-Jan-2018 2
A 04-Jan-2018 2
A 05-Jan-2018 1
A 06-Jan-2018 0
A 07-Jan-2018 1
A 08-Jan-2018 1
B 01-Jan-2018 0
B 02-Jan-2018 0
B 03-Jan-2018 1
B 04-Jan-2018 1
B 05-Jan-2018 1
B 06-Jan-2018 0
B 07-Jan-2018 0
B 08-Jan-2018 0


The dataset over here isn't straight forward to apply groupby. Meaning , the first row has the following implicit dates - 01 Jan , 02 Jan , 03 Jan , 04 Jan) second row has the dates - 07 Jan , 08-Jan and so on... The output needs to be the occurance of each date in the given date range...I understand I need to use date functionality to get all the dates in each row and then group it. But unsure of how to do this using pandas utilities
Reply


Messages In This Thread
Finding date count from a list of date range in pandas - by trillerducas72 - May-24-2018, 02:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 559 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  Function to Select a Date standenman 2 943 May-08-2023, 07:12 PM
Last Post: standenman
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,695 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
  [Pandas] Help with finding only non-matching rows LowEnd 3 3,548 Nov-12-2021, 02:34 PM
Last Post: jefsummers
  Sorting list from FTP by Date lastyle 2 2,586 Nov-02-2021, 05:46 PM
Last Post: ibreeden
  Does a pandas have a date without a time? AlekseyPython 6 4,924 Feb-10-2021, 09:24 AM
Last Post: Naheed
  Remove extra count columns created by pandas groupby spyf8 1 2,720 Feb-10-2021, 09:19 AM
Last Post: Naheed
  [split] Getting Index Error - list index out of range krishna 2 2,603 Jan-09-2021, 08:29 AM
Last Post: buran
  Comparing results within a list and appending to pandas dataframe Aryagm 1 2,344 Dec-17-2020, 01:08 PM
Last Post: palladium
  Cycle through Numpy range within another range(?) Zero01 0 2,015 Jul-31-2020, 02:37 PM
Last Post: Zero01

Forum Jump:

User Panel Messages

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