I know there is a simple implementation to do this but I cannot remember the syntax. Have a simple pandas time series and I want to summarize the data by month. Specifically I want to add data over months and years to get some summary of it. Can write it with slicing, but I remember seeing syntax that does it automatically.
import pandas as pd
df = Series(randn(100), index=pd.date_range('2012-01-01', periods=100))
a Multi-indexed Series with Years and sub endexed to months would be first prize.
Partial Answer:
ds.resample('M', how=sum) # for calendar monthly
ds.resample('A', how=sum) # for calendar yearly
Any idea how to elegantly get to multindexed by year sums?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…