Hi Michael,
well, indeed if you have a mixed-type DataFrame, grabbing frame.values
will return an object array.
In this case, maybe the best solution is just to cast back to float:
df = df.astype(float)
In [19]: df
Out[19]:
<class 'pandas.core.frame.DataFrame'>
DateRange: 10824 entries, 2010-06-01 00:00:00 to 2011-08-25 23:00:00
offset: <1 Hour>
Data columns:
Dew Point 10824 non-null values
Dry Bulb 10824 non-null values
Relative Humidity 10824 non-null values
Wet Bulb 10824 non-null values
dtypes: float64(1), object(3)
In [20]: df.astype(float)
Out[20]:
<class 'pandas.core.frame.DataFrame'>
DateRange: 10824 entries, 2010-06-01 00:00:00 to 2011-08-25 23:00:00
offset: <1 Hour>
Data columns:
Dew Point 10824 non-null values
Dry Bulb 10824 non-null values
Relative Humidity 10824 non-null values
Wet Bulb 10824 non-null values
dtypes: float64(4)
I would like to add a function to do type inference on object columns
to convert columns back to the right types. I have all the machinery
to do that already (from file parsing, etc.) but not sure what the API
should look like.
Note that you can do:
df.to_records()
to convert that data to a record array. it has some other options,
check the docstring (like you can exclude the index from the returned
array, etc.)
- Wes