Skip to content

Commit e9ec2b6

Browse files
author
Matt Roeschke
committed
Add another regression test for reading tz aware datetimeindex
1 parent 50e3ad6 commit e9ec2b6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

doc/source/whatsnew/v0.25.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ I/O
816816
- :func:`read_excel` now raises a ``ValueError`` when input is of type :class:`pandas.io.excel.ExcelFile` and ``engine`` param is passed since :class:`pandas.io.excel.ExcelFile` has an engine defined (:issue:`26566`)
817817
- Bug while selecting from :class:`HDFStore` with ``where=''`` specified (:issue:`26610`).
818818
- Fixed bug in :func:`DataFrame.to_excel()` where custom objects (i.e. `PeriodIndex`) inside merged cells were not being converted into types safe for the Excel writer (:issue:`27006`)
819+
- Bug in :meth:`read_hdf` where reading a timezone aware :class:`DatetimeIndex` would raise a ``TypeError`` (:issue:`11926`)
819820

820821
Plotting
821822
^^^^^^^^

pandas/tests/io/pytables/test_pytables.py

+17
Original file line numberDiff line numberDiff line change
@@ -5183,3 +5183,20 @@ def test_dst_transitions(self):
51835183
store.append('df', df)
51845184
result = store.select('df')
51855185
assert_frame_equal(result, df)
5186+
5187+
def test_read_with_where_tz_aware_index(self):
5188+
# GH 11926
5189+
periods = 10
5190+
dts = pd.date_range('20151201', periods=periods,
5191+
freq='D', tz='UTC')
5192+
mi = pd.MultiIndex.from_arrays([dts, range(periods)],
5193+
names=['DATE', 'NO'])
5194+
expected = pd.DataFrame({'MYCOL': 0}, index=mi)
5195+
5196+
key = 'mykey'
5197+
with ensure_clean_path(self.path) as path:
5198+
with pd.HDFStore(path) as store:
5199+
store.append(key, expected, format='table', append=True)
5200+
result = pd.read_hdf(path, key,
5201+
where="DATE > 20151130")
5202+
assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)