0

I have a pandas data frame with a two column multi index, as seen below

    var
    var1   var2  
0     1     3     
1     2     4     

Would it be possible to create a new 3rd column index, the first (mean) would be the original data and the second would have a function applied to it for example .rank()

    var
    var1            var2  
    mean  rank      mean  rank
0     1     0.5      3     0.5
1     2      1       4      1
Mustard Tiger
  • 3,520
  • 8
  • 43
  • 68
  • Does this answer your question? [Concatenate Pandas columns under new multi-index level](https://stackoverflow.com/questions/23600582/concatenate-pandas-columns-under-new-multi-index-level) – Joe Ferndz Mar 22 '21 at 23:10
  • @JoeFerndz I was looking for a way to do this with a single data frame, if i understand this I would need to make an identical copy and then merge it – Mustard Tiger Mar 23 '21 at 01:24
  • how are the numbers in the `rank` column calculated? They do not appear to be `rank`s of the other columns – piterbarg Mar 23 '21 at 19:11

0 Answers0