import pandas as pdfrom pandas import Timestamp
demo_data = {('AAAA', Timestamp('2014-12-31 00:00:00', freq='A-DEC')): 4.0, ('AAAA', Timestamp('2015-12-31 00:00:00', freq='A-DEC')): 1.0, ('AAAA', Timestamp('2016-12-31 00:00:00', freq='A-DEC')): 2.0, ('AAAA', Timestamp('2017-12-31 00:00:00', freq='A-DEC')): 12.0, ('BBBB', Timestamp('2015-12-31 00:00:00', freq='A-DEC')): 4.0, ('BBBB', Timestamp('2016-12-31 00:00:00', freq='A-DEC')): 3.0, ('CCCC', Timestamp('2012-12-31 00:00:00', freq='A-DEC')): 7.0, ('CCCC', Timestamp('2013-12-31 00:00:00', freq='A-DEC')): 4.0, ('CCCC', Timestamp('2014-12-31 00:00:00', freq='A-DEC')): 4.0, ('CCCC', Timestamp('2015-12-31 00:00:00', freq='A-DEC')): 21.0, ('CCCC', Timestamp('2016-12-31 00:00:00', freq='A-DEC')): 16.0}
demo = pd.Series(demo_data)
AAAA 2014-12-31 4.0 2015-12-31 1.0 2016-12-31 2.0 2017-12-31 12.0BBBB 2015-12-31 4.0 2016-12-31 3.0CCCC 2012-12-31 7.0 2013-12-31 4.0 2014-12-31 4.0 2015-12-31 21.0 2016-12-31 16.0
AAAA 2012-12-31 0.0
2013-12-31 0.0
2014-12-31 4.0 2015-12-31 1.0 2016-12-31 2.0 2017-12-31 12.0
2018-12-31 0.0BBBB 2012-12-31 0.0
2013-12-31 0.0
2014-12-31 0.0
2015-12-31 4.0 2016-12-31 3.0
2017-12-31 0.0
2018-12-31 0.0CCCC 2012-12-31 7.0 2013-12-31 4.0 2014-12-31 4.0 2015-12-31 21.0 2016-12-31 16.0
2017-12-31 0.0
2018-12-31 0.0
idx = pd.date_range(start='1-1-2012', periods=6, freq='1Y')demo.reindex(idx, level=1, fill_value=0)
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
demo.reindex(idx, level=1, fill_value=0)
) should IMO work*.