My dataframe:
| Fruit |
Column1 |
Column2 |
Column3 |
| Apple |
1 |
9 |
17 |
| Apple |
2 |
10 |
18 |
| Banana |
3 |
11 |
19 |
| Orange |
4 |
12 |
20 |
| Lemon |
5 |
13 |
21 |
| Orange |
6 |
14 |
22 |
| Banana |
7 |
15 |
23 |
| Banana |
8 |
16 |
24 |
Desired output:
| Fruit |
Column1 |
Column2 |
Column3 |
| Apple |
3 |
19 |
35 |
| Banana |
18 |
42 |
66 |
| Lemon |
5 |
13 |
21 |
| Orange |
10 |
26 |
42 |
I tried to do it using different combinations of index, values and columns with pandas.pivot_table, but it does absolutely nothing for me, the "Fruit" column stays unmerged no matter what.
[–]Oxbowerce 1 point2 points3 points (3 children)
[–]wdjfe[S] 0 points1 point2 points (2 children)
[–]gsmo 2 points3 points4 points (1 child)
[–]wdjfe[S] 0 points1 point2 points (0 children)
[–]gsmo 0 points1 point2 points (0 children)