相关疑难解决方法(0)

带字符串列的HDFStore会产生问题

我有一个熊猫数据帧myDF的几个字符串列(其dtype为object)和许多数字列.我尝试了以下方法:

d=pandas.HDFStore("C:\\PF\\Temp.h5")
d['test']=myDF
Run Code Online (Sandbox Code Playgroud)

我得到了这个结果:

C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\pandas\io\pytables.py:2446: PerformanceWarning: 

your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block2_values] 
[items->[0, 1, 3, 4, 5, 6, 9, 10, 292, 411, 412, 477, 478, 479, 495, 572, 581, 590, 599, 608, 617, 626, 635]]

  warnings.warn(ws, PerformanceWarning)
Run Code Online (Sandbox Code Playgroud)

看起来每个列都是一个字符串的问题.例如,如果我尝试

myDF[0].dtype
Run Code Online (Sandbox Code Playgroud)

我明白了

Out[38]: dtype('O')
Run Code Online (Sandbox Code Playgroud)

如何解决问题,即更改dtypefor string列,以便HDFStore可以将其视为字符串列?

*编辑*

更多信息请求

>>> pandas.__version__
Out[49]: '0.13.1'

>>> tables.__version__
Out[53]: '3.1.0'
Run Code Online (Sandbox Code Playgroud)

构建pandas数据框如下:

pandas.read_csv(fName,sep="|",header=None,low_memory=False)
Run Code Online (Sandbox Code Playgroud)

当我尝试

myDF.info()
Run Code Online (Sandbox Code Playgroud)

我明白了

Int64Index: …
Run Code Online (Sandbox Code Playgroud)

pytables python-3.x pandas

6
推荐指数
1
解决办法
5587
查看次数

如何解决HDFStore异常问题:无法找到正确的原子类型

我正在寻找关于什么类型的数据场景可能导致此异常的一般指导.我试过以各种方式按摩我的数据无济于事.

我已经搜索了这个例外几天了,经历了几次谷歌小组讨论,并没有提出调试的解决方案HDFStore Exception: cannot find the correct atom type.我正在阅读混合数据类型的简单csv文件:

Int64Index: 401125 entries, 0 to 401124
Data columns:
SalesID                     401125  non-null values
SalePrice                   401125  non-null values
MachineID                   401125  non-null values
ModelID                     401125  non-null values
datasource                  401125  non-null values
auctioneerID                380989  non-null values
YearMade                    401125  non-null values
MachineHoursCurrentMeter    142765  non-null values
UsageBand                   401125  non-null values
saledate                    401125  non-null values
fiModelDesc                 401125  non-null values
Enclosure_Type              401125  non-null values
...................................................
Stick_Length                401125  non-null values
Thumb                       401125  non-null values
Pattern_Changer             401125  non-null values …
Run Code Online (Sandbox Code Playgroud)

python hdf5 pandas

5
推荐指数
1
解决办法
4250
查看次数

标签 统计

pandas ×2

hdf5 ×1

pytables ×1

python ×1

python-3.x ×1