0

Dealing with a chemical dataset I'd like to do the following thing, that I'm illustrating with an example:

Let's say we have

formula      Temperature         value
 CO2             298               1
 LiVO3           300               5
 AgSO4           290               2
 H2O             87                3
 NaCl            674               4
 CO2             298               5
 LiVO3           300               6
 H2O             87                4
 NaCl            674               3

What I'd like to do is to process the above df by aggregating the value corresponding to formulas with the same temperatures. If I choose an add aggregation in the end I would like it to look something like

formula      Temperature         value
 CO2             298               6
 LiVO3           300               11
 AgSO4           290               2
 H2O             87                7
 NaCl            674               7

ANy suggestions on how to do that? I have tried to consider df.groupby() but the main point here is that I only want to aggregate values corresponding to compounds with the same temperature.

James Arten
  • 324
  • 1
  • 8

0 Answers0