I have got the following dataframe:
lst=[['01012021','A',100,'NaN'],['01012021','B',120,'NaN'],['01022021','A',140,5],['01022021','B',160,12],['01032021','A',180,20],['01032021','B',200,25]]
df1=pd.DataFrame(lst,columns=['Date','FN','AuM','NNA'])
I would like to generate a new column (AuM_2) which takes the starting value in column AuM and accumulates the entries in column NNA by the column Product. The end result should look like the below mentioned dataframe:
lst=[['01012021','A',100,'NaN','NaN'],['01012021','B',120,'NaN','NaN'],['01022021','A',140,5,105],['01022021','B',160,12,132],['01032021','A',180,20,125],['01032021','B',200,25,157]]
df2=pd.DataFrame(lst,columns=['Date','FN','AuM','NNA','AuM_2'])
Do you have any idea how I could generate column AuM_2 with groupby? Thank you for your assistance.