Skip to content

Commit 6625367

Browse files
TST: confirm bug in partial string multi-index slicing is fixed (GH12685) (#13559)
1 parent f20b41e commit 6625367

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pandas/tests/indexes/test_multi.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
import warnings
88

9-
from pandas import (date_range, MultiIndex, Index, CategoricalIndex,
9+
from pandas import (DataFrame, date_range, MultiIndex, Index, CategoricalIndex,
1010
compat)
1111
from pandas.core.common import PerformanceWarning
1212
from pandas.indexes.base import InvalidIndexError
@@ -2201,6 +2201,15 @@ def test_partial_string_timestamp_multiindex(self):
22012201
with assertRaises(KeyError):
22022202
df_swap.loc['2016-01-01']
22032203

2204+
# GH12685 (partial string with daily resolution or below)
2205+
dr = date_range('2013-01-01', periods=100, freq='D')
2206+
ix = MultiIndex.from_product([dr, ['a', 'b']])
2207+
df = DataFrame(np.random.randn(200, 1), columns=['A'], index=ix)
2208+
2209+
result = df.loc[idx['2013-03':'2013-03', :], :]
2210+
expected = df.iloc[118:180]
2211+
tm.assert_frame_equal(result, expected)
2212+
22042213
def test_rangeindex_fallback_coercion_bug(self):
22052214
# GH 12893
22062215
foo = pd.DataFrame(np.arange(100).reshape((10, 10)))

0 commit comments

Comments
 (0)