熊猫HDFStore警告

时间:2014-06-05 20:00:25

标签: python pandas

我想知道为什么HDFStore会在pandas中的字符串列上发出警告。我认为它可能是我真实数据库中的NaNs,但是在这里尝试它会给我两个列的警告,即使一个没有混合而且只是字符串。

使用.13.1 pandas和3.1.1表

In [75]: d1 = {1:{'Mix': 'Hello', 'Good': 'Hello'}}

In [76]: d2 = {2:{'Good':'Goodbye'}}

In [77]: d2_df = pd.DataFrame.from_dict(d2,orient='index')

In [78]: d_df = pd.DataFrame.from_dict(d1,orient='index')

In [80]: d = pd.concat([d_df,d2_df])

In [81]: d
Out[81]:
      Good    Mix
1    Hello  Hello
2  Goodbye    NaN

[2 rows x 2 columns]

In [84]: d.to_hdf('test_.h5','d')
/home/cschwalbach/venv/lib/python2.7/site-packages/pandas-0.13.1-py2.7-linux-x86_64.egg/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->block0_values] [items->['Good', 'Mix']]

  warnings.warn(ws, PerformanceWarning)

2 个答案:

答案 0 :(得分:3)

使用fixed格式存储时(如果您没有指定format,默认为fixed),则存储object dtypes(字符串为在pandas中存储为对象dtypes)。这些是可变长度格式,数组类型(CArray,EArray)中PyTables不支持这些格式,请参阅警告here

可以存储在format='table';有关存储固定长度字符串的docs,请参阅此处。

答案 1 :(得分:0)

NaN值是这里的问题。如果你设法用空字符串替换,警告就会消失。