I am doing function where I am grouping by ID and summing the $ value associated with those IDs with this code for python:
df = df.groupby([' Id'], as_index=False, sort=False)[["Amount"]].sum();
but it doesnt rename the column. As such I tried doing this :
`df = df.groupby([' Id'], as_index=False, sort=False)`[["Amount"]].sum();.reset_index(name ='Total Amount')
but it gave me error that TypeError: reset_index() got an unexpected keyword argument 'name'
So I tried doing this finally following this post:Python Pandas Create New Column with Groupby().Sum()
df = df.groupby(['Id'])[["Amount"]].transform('sum');
but it still didnt work.
What am I doing wrong?