Skip to content

Commit c74a250

Browse files
authored
adding test case for #899 (#901)
* adding test case for #899 * formatted black * fix for #899
1 parent 0cf1cb9 commit c74a250

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

pandas-stubs/core/series.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class _LocIndexerSeries(_LocIndexer, Generic[S1]):
198198
| list[str]
199199
| slice
200200
| _IndexSliceTuple
201+
| Sequence[_IndexSliceTuple]
201202
| Callable
202203
),
203204
# _IndexSliceTuple is when having a tuple that includes a slice. Could just

tests/test_series.py

+14
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ def test_multiindex_loc() -> None:
176176
check(assert_type(s.loc[1, "a"], int), np.int_)
177177

178178

179+
def test_multiindex_loc_str_tuple() -> None:
180+
s = pd.Series(
181+
[1, 2, 3, 4, 5, 6],
182+
index=pd.MultiIndex.from_product([["A", "B"], ["c", "d", "e"]]),
183+
dtype=int,
184+
)
185+
check(assert_type(s.loc[("A", "c")], int), np.int_)
186+
check(
187+
assert_type(s.loc[[("A", "c"), ("B", "d")]], "pd.Series[int]"),
188+
pd.Series,
189+
np.int_,
190+
)
191+
192+
179193
def test_types_boolean_indexing() -> None:
180194
s = pd.Series([0, 1, 2])
181195
s[s > 1]

0 commit comments

Comments
 (0)