2016-05-29 92 views
2

我有一個以熊貓日期戳爲索引的系列,我該如何對索引進行分片,以便我可以獲取特定月份的所有值?按月劃分時間戳

d = {'1993-01-01 00:00:00': 10, '1993-02-01 00:00:00': 12} 
s = pandas.Series(d) 
s.index = pandas.to_datetime(s.index, utc=True) 

回答

0

如果特定的月份,你的意思是1993年2月,那麼它只是:

s['1993-02'] 

1993-02-01 00:00:00+00:00 12 
dtype: int64 

如果你的意思是所有Februarys,那麼你做不到比以色列提供的更好。