Skip to content

Commit

Permalink
Fix: dataframe.loc int label could be warn (pandas-dev#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangjinghao authored Nov 8, 2023
1 parent 2710616 commit 94df875
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class _LocIndexerFrame(_LocIndexer):
@overload
def __setitem__(
self,
idx: MaskType | StrLike | _IndexSliceTuple | list[ScalarT],
idx: MaskType | StrLike | _IndexSliceTuple | list[ScalarT] | IndexingInt,
value: Scalar | NAType | NaTType | ArrayLike | Series | DataFrame | list | None,
) -> None: ...
@overload
Expand Down
10 changes: 10 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2290,6 +2290,16 @@ def test_loc_set() -> None:
df.loc["a"] = [3, 4]


def test_loc_int_set() -> None:
df = pd.DataFrame({1: [1, 2], 2: [3, 4]})
df.loc[1] = [3, 4]
df.loc[np.int_(1)] = pd.Series([1, 2])
df.loc[np.uint(1)] = pd.Series([1, 2])
df.loc[np.int8(1)] = pd.Series([1, 2])
df.loc[np.int32(1)] = [2, 3]
df.loc[np.uint64(1)] = [2, 3]


def test_loclist() -> None:
# GH 189
df = pd.DataFrame({1: [1, 2], None: 5}, columns=pd.Index([1, None], dtype=object))
Expand Down

0 comments on commit 94df875

Please sign in to comment.