Sample Pandas Dataframe:
ID Name COMMENT1 COMMENT2 NUM 1 dan hi hello 1 1 dan you friend 2 3 jon yeah nope 3 2 jon dog cat .5 3 jon yes no .1
I am trying to create a dataframe that groups by ID and NAME that concatenates COMMENT1 and COMMENT2 that also sums NUM.
This is what I'm looking for:
ID Name COMMENT1 COMMENT2 NUM 1 dan hi you hello friend 3 3 jon yeah yes nope no 3.1 2 jon dog cat .5
I tried using this:
input_df = input_df.groupby(['ID', 'NAME', 'COMMENT1', 'COMMENT2']).sum().reset_index()
But it doesn't work.
If I use this:
input_df = input_df.groupby(['ID']).sum().reset_index()
It sums the NUM column but leaves out all other columns.