Skip to content

Commit

Permalink
Re narwhals-dev#1483: change isinstance(..., int) to np.isscalar(); r…
Browse files Browse the repository at this point in the history
…esulting in AssertionError
  • Loading branch information
thevro committed Dec 5, 2024
1 parent 1323add commit b3d6451
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion narwhals/_pandas_like/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])

Expand Down

0 comments on commit b3d6451

Please sign in to comment.