I have a data that stores % change in value for stocks over one day, month, three months and year.
ID daychange monthchange trimonthchange yearchange
UNITY 0.001666 0.398450 0.411581 0.689139
SSOM -0.033359 0.040816 1.174840 3.047619
PNSC -0.004953 -0.053006 0.158677 0.224932
PICT -0.002027 -0.069696 0.041143 0.310791
PIBTL -0.014848 0.129362 0.459846 0.287100
I want to get:
- averages for each of the 4 time periods based on the ID name. For instance "UNITY" "SSOM" "PNSC" are to be grouped and their average be calculated for each time period (i.e. avg daychange for the group, avg monthchange for the group and so on).
- that average data to be put in a separate csv file with a new single row (instead of "UNITY" "SSOM" "PNSC") and the average of each time periods for the group.
I have tried df.mean(axis = 1)
but that doesn't do the job.
Any help will be dearly appreciated! THANKS