Skip to content

Commit 727e2d4

Browse files
Backport PR #45453 REF: move np_can_hold_element to mgr method (#45453) (#45873)
Co-authored-by: jbrockmendel <[email protected]>
1 parent f0dfe68 commit 727e2d4

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

pandas/core/internals/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def setitem_inplace(self, indexer, value) -> None:
187187
# dt64/td64, which do their own validation.
188188
value = np_can_hold_element(arr.dtype, value)
189189

190-
self.array[indexer] = value
190+
arr[indexer] = value
191191

192192
def grouped_reduce(self, func, ignore_failures: bool = False):
193193
"""

pandas/core/series.py

-7
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
)
6363

6464
from pandas.core.dtypes.cast import (
65-
can_hold_element,
6665
convert_dtypes,
6766
maybe_box_native,
6867
maybe_cast_pointwise_result,
@@ -1145,12 +1144,6 @@ def __setitem__(self, key, value) -> None:
11451144

11461145
def _set_with_engine(self, key, value) -> None:
11471146
loc = self.index.get_loc(key)
1148-
dtype = self.dtype
1149-
if isinstance(dtype, np.dtype) and dtype.kind not in ["m", "M"]:
1150-
# otherwise we have EA values, and this check will be done
1151-
# via setitem_inplace
1152-
if not can_hold_element(self._values, value):
1153-
raise ValueError
11541147

11551148
# this is equivalent to self._values[key] = value
11561149
self._mgr.setitem_inplace(loc, value)

0 commit comments

Comments
 (0)