title: Pandas: ignore null values when using .astype(str)?
body: <p>So I have a dataframe, call it <code>TABLE</code> and I'm using Pandas with Python 2.7 to analyze it. It's mostly categorical data so right now my goal is to have a summary of my table where I list each column name and the average length of the values in that column.
  Example table:</p>
  
  <pre><code>   A      B     C    E    F
  0  djsdd  973  348f  NaN  abcd
  1  dsa    49   34h5  NaN  NaN
  </code></pre>
  
  <p>Then my desired output would be something like:</p>
  
  <pre><code>Column AvgLength
  A      4.0
  B      2.5
  C      4.0
  E      NaN
  F      4.0
  </code></pre>
  
  <p>Now the first problem I had was that there are some numerical values in the dataset. I thought I could resolve that by using <code>.astype(str)</code> so I did the following:</p>
  
  <pre><code>for k in TABLE:
      print "%s\t %s"%(k,TABLE[k].astype(str).str.len().mean())
  </code></pre>
  
  <p>The issue now is that it looks to me like <code>.astype(str)</code> is converting the null values to strings because I ended up with the following output:</p>
  
  <pre><code>Column AvgLength
  A      4.0
  B      2.5
  C      4.0
  E      3.0
  F      3.5
  </code></pre>
  
  <p>Notice that column E containing the null values is giving me an average length of 3, and column F is giving me an average of 3.5. My understanding is this happened because it's taking the length of the string "NaN."</p>
  
  <p>Is there some way to do what I want and ignore the Null values? Or is there a completely different approach I should be taking (I'm very new to pandas)?</p>
  
  <p>(I did read about <code>.dropna()</code> but I don't want to omit all columns that might contain null values because some columns may have null values alongside data. I want to just ignore the null values from my mean).</p>