0

I want to subtract the mean of each column of my DataFrame for each part of it (ie for each index value "hostname"). I tried this :

for host in hostnames:
  df_temp = df.loc[host]
  df_temp = df_temp.subtract(df_temp.mean(axis=0))
  df.loc[host] = df_temp

... but it is taking forever (even for one loop).

Thank you for your help !

Maxime
  • 11
  • 2
  • Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Feb 11 '18 at 20:17

1 Answers1

0

Found it : Didn't know about "level" parameter

df - df.mean(axis=0,level=0)
Maxime
  • 11
  • 2