Description
Code Sample
import pandas as pd
df = pd.DataFrame({'string': ['a', 'b'], 'number': [1.0, 2.0], 'mix': ['a', 2.0]})
df.to_hdf('foo.h5', 'data')
Problem description
The problem is related to the feature added in #3622. The warning for types that cannot be saved as c-types applies for all object
columns if any such column exists in the data frame. If all columns are either strings or numbers (but not mixed within a column) no warning is produced (which is expected).
Output
python3.6/site-packages/pandas/core/generic.py:2530: PerformanceWarning:
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block1_values] [items->['string', 'mix']]
pytables.to_hdf(path_or_buf, key, self, **kwargs)
Expected Output
Warnings only for column mix
.
INSTALLED VERSIONS
commit : None
python : 3.6.8.final.0
python-bits : 64
OS : Linux
OS-release : 4.15.0-58-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.1
numpy : 1.17.1
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : 2.7.0
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : 3.5.2
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None