From b3d6451b6faef115363bf5f19803c30786c7e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20Everley=20R=C3=B6hrkasten?= Date: Thu, 5 Dec 2024 19:14:39 +0100 Subject: [PATCH] Re #1483: change isinstance(..., int) to np.isscalar(); resulting in AssertionError --- narwhals/_pandas_like/series.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/narwhals/_pandas_like/series.py b/narwhals/_pandas_like/series.py index fe5eb1f3b8..70d0508808 100644 --- a/narwhals/_pandas_like/series.py +++ b/narwhals/_pandas_like/series.py @@ -18,6 +18,7 @@ from narwhals._pandas_like.utils import select_columns_by_name from narwhals._pandas_like.utils import set_axis from narwhals._pandas_like.utils import to_datetime +from narwhals.dependencies import get_numpy from narwhals.utils import Implementation from narwhals.utils import import_dtypes_module @@ -112,7 +113,8 @@ def __getitem__(self, idx: int) -> Any: ... def __getitem__(self, idx: slice | Sequence[int]) -> Self: ... def __getitem__(self, idx: int | slice | Sequence[int]) -> Any | Self: - if isinstance(idx, int): + np = get_numpy() + if np.isscalar(idx): return self._native_series.iloc[idx] return self._from_native_series(self._native_series.iloc[idx])