In [9]:
obsids = ['ESP_012345_6789', 'ESP_987654_3210']
imgids = ['APF00006np', 'APF0001imm']
data = [4.3, 9.8]
df = pd.DataFrame(dict(obsids=obsids, imgids=imgids, data=data))
df.to_hdf('testdf_no_cats.hdf', 'df',format='t', data_columns=True)
df.obsids = df.obsids.astype('category')
df.imgids = df.imgids.astype('category')
df.to_hdf('testdf_with_cats.hdf', 'df',format='t', data_columns=True)
print("No categories:")
print(pd.read_hdf('testdf_no_cats.hdf', 'df', where='obsids=B'))
print("With categories:")
print(pd.read_hdf('testdf_with_cats.hdf', 'df', where='obsids=B'))
In [10]:
pd.show_versions()
In [ ]: