I have a data set which looks like follows (Values changed):
Value A B
ABC 20 5
ABC 20 5
ABC 20 5
ABC 20 5
XYZ 20 5
XYZ 20 5
XYZ 20 5
I create a new column C using
df['C'] = df['A']/df['B']
I obtain the df:
Value A B C
ABC 20 5 4
ABC 20 5 4
ABC 20 5 4
ABC 20 5 4
XYZ 20 5 4
XYZ 20 5 4
XYZ 20 5 4
XYZ 20 5 4
Until here everything works fine. Now When I try to use group by on the df, it doesn't give the sum of the third column(the one I created). I am using the following code line for group by
df.groupby('Value').sum()
The result is:
Value A B
ABC 60 15
XYZ 60 15
Any reason why it might be doing that?