I have a pandas dataframe that structurally looks like this:
[ [\'x\', \'1\', \'-7\'] [\'x\', \'2\', \'-2\'] [\'y\', \'3\', \'-1\'] [\'y\', \'4\'
setup I converted your string numbers to actual numbers
df = pd.DataFrame( [ ['x', '1', '-7'], ['x', '2', '-2'], ['y', '3', '-1'], ['y', '4', '-3'] ] ) df[1] = pd.to_numeric(df[1]) df[2] = pd.to_numeric(df[2])
solution
df.groupby(0).sum()