0

I am trying to convert Table A to Table B using python pandas dataframe, duplicating the records based on the number of hours between StartTime and EndTime

Table A

CustomerID StartTime EndTime
abc 2022-01-18 15:00:00 2022-01-18 18:00:00
xyz 2022-01-18 01:00:00 2022-01-18 01:00:00

Table B

CustomerID HourlyTime
abc 2022-01-18 15:00:00
abc 2022-01-18 16:00:00
abc 2022-01-18 17:00:00
abc 2022-01-18 18:00:00
xyz 2022-01-18 01:00:00

I have tried solving this by duplicating all rows twice, but it did not account for the data which had start and end time difference of more than 2 hours.

wjandrea
  • 28,235
  • 9
  • 60
  • 81

0 Answers0