Filling gaps for cumulative sum with Pandas
问题 I'm trying to calculate the inventory of stocks from a table in monthly buckets in Pandas. This is the table: Goods | Incoming | Date -------+------------+----------- 'a' | 10 | 2014-01-10 'a' | 20 | 2014-02-01 'b' | 30 | 2014-01-02 'b' | 40 | 2014-05-13 'a' | 20 | 2014-06-30 'c' | 10 | 2014-02-10 'c' | 50 | 2014-05-10 'b' | 70 | 2014-03-10 'a' | 10 | 2014-02-10 This is my code so far: import pandas as pd df = pd.DataFrame({ 'goods': ['a', 'a', 'b', 'b', 'a', 'c', 'c', 'b', 'a'], 'incoming':