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])