如何将索引中带有空格字符的数据(例如:äüö)存储到 HDF 文件中。
创建一个数据框:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(8, 4),
columns=['A','B','C','D'],
index=["a", "ä", "b", "c", "d", "e", "f", "g"])
df.to_hdf("test.h5", "data")
从 hdf 文件中读取数据:
store = pd.HDFStore("test.h5")
缺失索引:
In [17]: store.data
Out[17]:
A B C D
a 0.859861 -1.017473 -0.095029 0.220382
0.472394 0.658839 0.494681 -0.350250
b 1.180679 0.513142 1.286615 0.807974
c -0.382927 1.983893 0.553454 -0.246470
d -1.738026 2.050707 0.820716 -0.564973
e -0.104748 0.926204 -0.543239 -0.632866
f 0.886118 0.948541 1.759265 -0.937207
g -1.670633 0.069873 0.037105 -0.809620