Skip to content

Commit 0c9c6d8

Browse files
authored
perf: simplify pandas scatter (#2154)
simplify pandas scatter
1 parent de2e99c commit 0c9c6d8

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

narwhals/_pandas_like/series.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,8 @@ def ewm_mean(
227227

228228
def scatter(self: Self, indices: int | Sequence[int], values: Any) -> Self:
229229
if isinstance(values, self.__class__):
230-
# .copy() is necessary in some pre-2.2 versions of pandas to avoid
231-
# `values` also getting modified (!)
232-
_, values = align_and_extract_native(self, values)
233230
values = set_index(
234-
values.copy(),
231+
values._native_series,
235232
self._native_series.index[indices],
236233
implementation=self._implementation,
237234
backend_version=self._backend_version,

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from narwhals.typing import IntoDataFrame
2323
from narwhals.typing import IntoFrame
2424

25-
MIN_PANDAS_NULLABLE_VERSION = (1, 5)
25+
MIN_PANDAS_NULLABLE_VERSION = (2,)
2626

2727
# When testing cudf.pandas in Kaggle, we get an error if we try to run
2828
# python -m cudf.pandas -m pytest --constructors=pandas. This gives us

0 commit comments

Comments
 (0)