我有这个pandas DataFrame:
<class 'pandas.core.frame.DataFrame'>
Float64Index: 880 entries, -440.0 to 439.0
Data columns (total 7 columns):
Channel 3 (A3) 880 non-null values
Channel 4 (A4) 880 non-null values
Channel 5 (A5) 880 non-null values
Channel 6 (A6) 880 non-null values
Channel 7 (B1) 880 non-null values
Channel 8 (B2) 880 non-null values
Channel 9 (B3) 880 non-null values
dtypes: float64(7)
所以,这里dtypes告诉我,我有7次浮动64,但是当我看到成员dtypes时:
df.dtypes
Channel 3 (A3) float64
Channel 4 (A4) float64
Channel 5 (A5) float64
Channel 6 (A6) float64
Channel 7 (B1) float64
Channel 8 (B2) float64
Channel 9 (B3) float64
dtype: object
Q1:为什么在那里说'对象'?
以下是我首先发现这一点的方法: 我试图把它保存为hdf并得到一个很大的性能警告:
/Users/maye/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas-0.12.0_1007_g6eba2e4-py2.7-macosx-10.6-x86_64.egg/pandas/io/pytables.py:2325: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->unicode,key->axis0] [items->None]
warnings.warn(ws, PerformanceWarning)
/Users/maye/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas-0.12.0_1007_g6eba2e4-py2.7-macosx-10.6-x86_64.egg/pandas/io/pytables.py:2325: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->unicode,key->block0_items] [items->None]
warnings.warn(ws, PerformanceWarning)
Q2:HDF存储尚不支持float64,还是这个错误?
我的熊猫版:'0.12.0-1007-g6eba2e4' 我首先使用read_excel创建了这个数据帧,进行了一些清理并使用df.convert_objects()来完成我的float64数据类型,或者我希望如此。
编辑:unicode列名称是警告的原因,另请参阅Jeff的评论。
答案 0 :(得分:2)
对于Q1:
DataFrame.dtypes
是一个Series
对象,其中dtype是一个对象。你可以尝试:
print type(df.dtypes)
print df.dtypes.dtype
对于Q2,我尝试了以下代码,没有警告,你能发布一些可以重现警告的代码吗?
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(10, 5))
df.to_hdf("test.hdf", "data")