0

Currently, I can generate quarterly, monthly and yearly index by changing frequency in following code.

df['period_index'] = pd.PeriodIndex(df.Date, freq='Q')

Is there a way to tweak freq and get semi annual index?

Lopez
  • 461
  • 5
  • 19

1 Answers1

0

There's a bit of a work-around if you use date_range first:

pd.PeriodIndex(pd.date_range(df.Date.min(), df.Date.max(), freq="6M"))
Ted
  • 1,189
  • 8
  • 15