pandas time series: drop date from index

不想你离开。 提交于 2021-01-29 15:46:04

问题


I have a pandas DataFrame indexed by a DatetimeIndex that holds a time series, i.e. some data as a function of time. Now I would like to plot the behavior over the day regardless of the date. To do so I drop the date:

for date, group in df.groupby(by = df.index.date):
  # drop date
  group.index = group.index.timetz

However, like this I lose a lot of convenience functions of a DatetimeIndex, e.g. it is no longer possible to do things like

df[df.index.hour > 9]

Is there a better way to drop the date?

来源:https://stackoverflow.com/questions/61878736/pandas-time-series-drop-date-from-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!