Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. type(df.index)
  2.  
  3. type(df.index)
  4.  
  5. class 'pandas.tseries.period.PeriodIndex'
  6.  
  7. VAR(mdata)
  8.  
  9. Given a pandas object and the index does not contain dates
  10.  
  11. df.index = pandas.DatetimeIndex(df.index)
  12.  
  13. cannot convert Int64Index->DatetimeIndex
  14.  
  15. In [25]: pidx = pd.period_range('2012-01-01', periods=10)
  16.  
  17. In [26]: pidx
  18. Out[26]:
  19. <class 'pandas.tseries.period.PeriodIndex'>
  20. [2012-01-01, ..., 2012-01-10]
  21. Length: 10, Freq: D
  22.  
  23. In [27]: pidx.to_timestamp()
  24. Out[27]:
  25. <class 'pandas.tseries.index.DatetimeIndex'>
  26. [2012-01-01, ..., 2012-01-10]
  27. Length: 10, Freq: D, Timezone: None
  28.  
  29. idx.astype('datetime64[ns]')
  30.  
  31. idx.to_period(freq='D')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement