So I have this pandas DataFrame, with 5 columns and like 100000 rows. Here's example:
V1 V2 V3 V4 V5
0 2014 Alfa Romeo 159 1 157
1 2014 Alfa Romeo GIULIETTA 1 119
2 2014 Alfa Romeo GIULIETTA 3 119
What I want to do is to sum values in column V4 IF values in V1, V2, V3 and V5 are exactly the same.
V1 V2 V3 V4 V5
0 2014 Alfa Romeo 159 1 157
1 2014 Alfa Romeo GIULIETTA 4 119
At first I thought that groupby would do the job, but when I did
df.groupby(['V1', V2','V3', 'V5' ]).sum()
I lost some of the information in column V3, for example, I should have 10 different types of colors but now I have only 3. How to solve that?