title: Find all columns of dataframe in Pandas whose type is float, or a particular type?
body: <p>I have a dataframe, df, that has some columns of type float64, while the others are of object. Due to the mixed nature, I cannot use </p>
  
  <pre><code>df.fillna('unknown') #getting error "ValueError: could not convert string to float:"
  </code></pre>
  
  <p>as the error happened with the columns whose type is float64 (what a misleading error message!)</p>
  
  <p>so I'd wish that I could do something like </p>
  
  <pre><code>for col in df.columns[&lt;dtype == object&gt;]:
      df[col] = df[col].fillna("unknown")
  </code></pre>
  
  <p>So my question is if there is any such filter expression that I can use with df.columns?</p>
  
  <p>I guess alternatively, less elegantly, I could do:  </p>
  
  <pre><code> for col in df.columns:
          if (df[col].dtype == dtype('O')): # for object type
              df[col] = df[col].fillna('') 
              # still puzzled, only empty string works as replacement, 'unknown' would not work for certain value leading to error of "ValueError: Error parsing datetime string "unknown" at position 0" 
  </code></pre>
  
  <p>I also would like to know why in the above code replacing '' with 'unknown' the code would work for certain cells but failed with a cell with the error of "ValueError: Error parsing datetime string "unknown" at position 0" </p>
  
  <p>Thanks a lot!</p>
  
  <p>Yu</p>