2016-05-29 90 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,那么你做不到比以色列提供的更好。