Skip to content

Commit f6f7bb0

Browse files
shirzady1934shirzady1934
and
shirzady1934
authored
resolving issue 1162 I change Hashable to HashableT in _LocIndexerFrame and it'… (pandas-dev#1165)
* issue 1162 I change Hashable to HashableT in _LocIndexerFrame and it's fine * issue 1162 added test_loc_list_str function for test loc issue with list of str's * issue 1162 added test_loc_list_str function for test loc issue with list of str's and instlled pre-commit --------- Co-authored-by: shirzady1934 <[email protected]>
1 parent 4b99ad8 commit f6f7bb0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas-stubs/core/frame.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class _LocIndexerFrame(_LocIndexer, Generic[_T]):
185185
IndexType
186186
| MaskType
187187
| Callable[[DataFrame], IndexType | MaskType | Sequence[Hashable]]
188-
| list[Hashable]
188+
| list[HashableT]
189189
| tuple[
190190
IndexType
191191
| MaskType

tests/test_frame.py

+12
Original file line numberDiff line numberDiff line change
@@ -3586,6 +3586,18 @@ def test_in_columns() -> None:
35863586
check(assert_type(df.groupby(by=cols).sum(), pd.DataFrame), pd.DataFrame)
35873587

35883588

3589+
def test_loc_list_str() -> None:
3590+
# GH 1162 (PR)
3591+
df = pd.DataFrame(
3592+
[[1, 2], [4, 5], [7, 8]],
3593+
index=["cobra", "viper", "sidewinder"],
3594+
columns=["max_speed", "shield"],
3595+
)
3596+
3597+
result = df.loc[["viper", "sidewinder"]]
3598+
check(assert_type(result, pd.DataFrame), pd.DataFrame)
3599+
3600+
35893601
def test_insert_newvalues() -> None:
35903602
df = pd.DataFrame({"a": [1, 2]})
35913603
ab = pd.DataFrame({"col1": [1, 2], "col2": [3, 4]})

0 commit comments

Comments
 (0)