Closed
Description
This should work, but the assert fails:
import pandas as pd
df = pd.DataFrame({'a': [1,2,3]})
df.index = pd.DatetimeIndex([1234567890123456787, 1234567890123456788, 1234567890123456789])
df.index = df.index.tz_localize('UTC') # this line makes the index name go away
df.index.name = 'expected'
df.to_hdf('hello.h5', 'world', format='table')
df2 = pd.read_hdf('hello.h5', 'world')
assert df2.index.name == df.index.name, "HDF5 stored name not expected: {}".format(df2.index.name)
It works fine if you don't localize the DatetimeIndex, or if you don't use format='table'.
The index name "expected" is actually stored in the "info" attribute inside the HDF5 file whether it's localized or not. But the format is slightly different. If not localized:
(dp7
Vindex_name
p8
Vexpected
If localized:
(tRp10
sVindex_name
p11
Vexpected
I don't know enough to say whether the bug is in read_hdf(), to_hdf(), or PyTables.
I'm using Pandas 0.18.1.