I am trying to unify certain columns of my csv with pandas. The problem is that I want to add the values of Imp and Rev but the Categories I want them to come together and look something like this:
sitio_id;url;Imp;Rev;Categorias
http://url.com/;19472;6,31;Sports, Auto Racing, Bodybuilding, Boxing, Pro Basketball, Tennis, Volleyball, World Soccer, Auto Racing, Bodybuilding, Boxing, Pro Basketball, Tennis, Volleyball, World Soccer
csv:
sitio_id;url;Imp; Rev ; eCPM ;Categorias
104521;http://url.com/;18984;15.8;0.83;Sports, Auto Racing, Bodybuilding, Boxing, Pro Basketball, Tennis, Volleyball, World Soccer
70209;http://url.com/;488;0.51;1.04;Sports, Auto Racing, Bodybuilding, Boxing, Pro Basketball, Tennis, Volleyball, World Soccer
Try using a group by:
df = df.groupby(['sitio_id', 'url'])['Imp','Rev'].sum()['Categorias'].apply(lambda x: "{%s}" % ', '.join(x))