我有这个熊猫数据框:
<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 次 float64,但是当我查看成员 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 存储尚不支持 float64s 还是这是一个错误?
我的 pandas 版本:'0.12.0-1007-g6eba2e4' 我首先使用 read_excel 创建了这个数据框,进行了一些清理,最后使用 df.convert_objects() 来获取我的 float64 数据类型,或者我希望如此。
编辑:unicode 列名是警告的原因,另请参阅下面的 Jeff 评论。