问题
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