Is there a function in python to rename data points and then flip the column and rows

Viewed 18

I have a sample data from a very large data set. Is there a code that could turn the below table into the output table

What I would like to achieve is, a way to find how many times a company names occurs (eg A 3 times) and to suffix each occurance into an index for that company. Then to flip the rows and columns as shown below.

Input table =

company revenue
A 10
A 20
A 30
B 10
B 15

Output table =

A_1 A_2 A_3 B_1 B_2
revenue 10 20 30 10 15
0 Answers
Related