A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/13884 below:

Round trip through HDF5 with format=table and localized DatetimeIndex discards index name · Issue #13884 · pandas-dev/pandas · GitHub

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.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4