title: Pandas - Compute z-score for all columns
body: <p>I have a dataframe containing a single column of IDs and all other columns are numerical values for which I want to compute z-scores. Here's a subsection of it:</p>
  
  <pre><code>ID      Age    BMI    Risk Factor
  PT 6    48     19.3    4
  PT 8    43     20.9    NaN
  PT 2    39     18.1    3
  PT 9    41     19.5    NaN
  </code></pre>
  
  <p>Some of my columns contain NaN values which I do not want to include into the z-score calculations so I intend to use a solution offered to this question: <a href="https://stackoverflow.com/questions/23451244/how-to-zscore-normalize-pandas-column-with-nans">how to zscore normalize pandas column with nans?</a></p>
  
  <pre><code>df['zscore'] = (df.a - df.a.mean())/df.a.std(ddof=0)
  </code></pre>
  
  <p>I'm interested in applying this solution to all of my columns except the ID column to produce a new dataframe which I can save as an Excel file using</p>
  
  <pre><code>df2.to_excel("Z-Scores.xlsx")
  </code></pre>
  
  <p>So basically; how can I compute z-scores for each column (ignoring NaN values) and push everything into a new dataframe?</p>
  
  <p>SIDENOTE: there is a concept in pandas called "indexing" which intimidates me because I do not understand it well. If indexing is a crucial part of solving this problem, please dumb down your explanation of indexing.</p>