get sum of column before a date python

35

dfx['colAsum'] = dfx.apply(lambda x: df.loc[(df.date >= x.StartDate) & 
                                            (df.date <= x.EndDate), 'colA'].sum(), axis=1)

Comments

Submit
0 Comments