How to get period duration in pandas? For example, if I have data
PeriodIndex Value
2017Q1 1.156355
2017Q2 0.815639
2017Q3 0.798100
2017Q4 1.027752
How do I get duration of each of the indeces? I could do end_time - start_time
, but that gets it slightly wrong like Timedelta('30 days 23:59:59.999999')
for January and you have to round that somehow. As I need to multiply the value by amount of days, I can also resample the data to days, ffil, then resample back to Q with sum, but that doesn't seem very efficient.
EDIT: Of course in my example I can just multiply with timedelta/timedelta('1 day')
, but in general if duration of period is needed, is there no built in function?