title: Python How to convert a float as hex to decimal
body: <p>I've read in some data from a csv file with pandas. The data is incomplete and therefore contains many nan values.
  I want to add a column to the data which converts the hex values to decimal values. Unfortunately, the column with the hex values are all read as floats, not strings because they just happen to have those values.
  Example data</p>
  
  <pre><code>   val
  0 20.0
  1  nan
  2 20.0
  </code></pre>
  
  <p>The simple way to convert a hex to decimal in python seems to be:<code>int('20.0',16)</code>, which should yield <code>32</code>.</p>
  
  <p>However, since this is pandas I cannot convert the values to int, or at least I keep getting an error stating that.
  My current code is:</p>
  
  <pre><code>df['valdec'] = np.where(np.isnan(df['val']), 
                      df['val'], 
                      int(df['val'].astype(int).astype(str), 16))
  </code></pre>
  
  <p>This fails with the error:</p>
  
  <blockquote>
    <p>ValueError: Cannot convert NA to integer</p>
  </blockquote>
  
  <p>without the <code>astype(int)</code> the value is <code>"20.0"</code> which cannot be converted.
  Is there another way to interpret a float value as a hex value and convert to decimal when working with pandas dataframe?</p>