Bottom Page

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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  itertuples, datetime, pandas, groupby, in range karlito 0 188 Nov-29-2019, 11:35 AM
Last Post: karlito
  how to list/count the number of dictionaries paul18fr 2 107 Nov-18-2019, 09:50 PM
Last Post: paul18fr
  Problem with date type (object to datetime) karlito 6 271 Oct-16-2019, 08:07 AM
Last Post: karlito
  Trying to Pass date to pandas search from input prompt curranjohn46 1 139 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Need help passing date to pandas query curranjohn46 1 235 Oct-10-2019, 09:59 AM
Last Post: curranjohn46
  Pandas Import CSV count between numerical values within 1 Column ptaylor520 3 260 Jul-16-2019, 08:13 AM
Last Post: ptaylor520
  Pandas converting date to epoch randor 2 384 Jul-16-2019, 02:41 AM
Last Post: scidam
  replace nan values by mean group by date.year, date.month wissam1974 4 641 Jul-06-2019, 02:00 AM
Last Post: wissam1974
  Pandas: faster method to count occurrences frame 0 757 May-26-2019, 07:45 PM
Last Post: frame
  Pandas and Date: problem with operator.How to resolve frame 6 1,213 May-13-2019, 05:50 PM
Last Post: frame

Forum Jump:


Users browsing this thread: 1 Guest(s)