I would like to combine rows of the same dataframe, more precisely, to take rows that have the same values in a specific column and create only one row. Here is an example:
I have the following dataframe:
te= {'TEAM': ['HC','TC','HC','BC','TC','BC'],
'A1': [22,25,27,35,31,41],
'A2': [20,50,70,11,14,12]
}
df = pd.DataFrame(te,columns= ['TEAM', 'A1', "A2"])
print (df)
TEAM A1 A2
0 HC 22 20
1 TC 25 50
2 HC 27 70
3 BC 35 11
4 TC 31 14
5 BC 41 12
and I would like to form a row for the three possibles values of the column TEAM such as the expected output look like this:
TEAM A1 A2 A1(1) A2(1)
0 HC 22 20 27 70
1 TC 25 50 31 14
2 BC 35 11 41 12
How can I do that ?
35 11 41 12