Converting PeriodIndex to DateTimeIndex?

前端 未结 2 1199
野趣味
野趣味 2020-12-31 18:57

I have a question regarding converting a tseries.period.PeriodIndex into a datetime.

I have a DataFrame which looks like this:

               colors      c         


        
2条回答
  •  庸人自扰
    2020-12-31 19:12

    You can also use the following to get exactly the same result.

    idx.astype('datetime64[ns]') 
    

    To convert back to period, you can do:

     idx.to_period(freq='D')
    

提交回复
热议问题