I have a dataframe and i would like to find the percentage difference of values in a column within a group.
An example of a group is df.groupby(['race', 'tyre', 'stint']).get_group(("Australian Grand Prix", "Super soft", 1))
I would like to find out what is the percentage distribution of "time diff" values for each row of the group.
Her is the dataframe in dictionary format.There will be many other groups, but below df only shows the first group.
{'driverRef': {0: 'vettel',
1: 'raikkonen',
2: 'rosberg',
4: 'hamilton',
6: 'ricciardo',
7: 'alonso',
14: 'haryanto'},
'race': {0: 'Australian Grand Prix',
1: 'Australian Grand Prix',
2: 'Australian Grand Prix',
4: 'Australian Grand Prix',
6: 'Australian Grand Prix',
7: 'Australian Grand Prix',
14: 'Australian Grand Prix'},
'stint': {0: 1.0, 1: 1.0, 2: 1.0, 4: 1.0, 6: 1.0, 7: 1.0, 14: 1.0},
'total diff': {0: 125147.50728499777,
1: 281292.0366694695,
2: 166278.41312954266,
4: 64044.234019635056,
6: 648383.28046950256,
7: 400675.77449897071,
14: 2846411.2560531585},
'tyre': {0: u'Super soft',
1: u'Super soft',
2: u'Super soft',
4: u'Super soft',
6: u'Super soft',
7: u'Super soft',
14: u'Super soft'}}