I have this DataFrame
{'a': {1: 3535226,2: 3776193,3: 3782454, 4: 3206345},
'b': {1: 1478432,2: 1625943,3: 1617503,4: 1414382},
'c': {1: 1596643,2: 1841902, 3: 1928081,4: 1648894},
'a_revenue': {1: 23343.44,2: 28113.64,3: 14166.92,4: 19828.980},
'b_revenue': {1: 9000.48, 2: 9997.9, 3: 9203.92, 4: 7927.66},
'c_revenue': {1: 2205.91, 2: 2208.66, 3: 2374.48, 4: 2439.30}}
Is there another way besides my way to divide each revenue column by its column (a_revenue/a and so on)?
I did it this way:
data = [(df.iloc[:,le+3] / df.iloc[:,le])for le in range(len(df.columns)-3)]
columns = [x,y,z]
index = ....
pd.DataFrame(data=data, index=index, column=columns)
It worked but I feel that there must be another way that I just cant figure out.
Thank you!