I currently have the following dataframe: I want to group by probeset column and get a single value for each phchp subject by adding up the data with the same probeset values
Probeset phchp230v2 phchp273v3 phchp367v3
0 1554784_at 0.000000 0.000000 0.000000
1 1554784_at 0.000000 0.000000 0.000000
2 212983_at 0.244668 0.032524 0.113343
3 212983_at 0.022178 0.013750 0.011871
4 1566643_a_at 0.048200 0.089618 0.046528
What I'm looking for is this:
Probeset phchp230v2 phchp273v3 phchp367v3
0 1554784_at 0 0 0
1 1554784_at 0 0 0
2 212983_at 0.244668 0.046274 0.125214
3 212983_at 0.244668 0.046274 0.125214
4 1566643_a_at 0.048200 0.089618 0.046528
I've tried the following to no success, it does not group correctly:
for x in df_out:
if 'phchp' in x:
df_out[x] = df_out.groupby(['Probeset'])[x].sum()