MCPcopy
hub / github.com/pandas-dev/pandas / setitem_inplace

Method setitem_inplace

pandas/core/internals/managers.py:2221–2247  ·  view source on GitHub ↗

Set values with indexer. For SingleBlockManager, this backs s[indexer] = value This is an inplace version of `setitem()`, mutating the manager/values in place, not returning a new Manager (and Block), and thus never changing the dtype.

(self, indexer, value)

Source from the content-addressed store, hash-verified

2219 return self._block._can_hold_na
2220
2221 def setitem_inplace(self, indexer, value) -> None:
2222 """
2223 Set values with indexer.
2224
2225 For SingleBlockManager, this backs s[indexer] = value
2226
2227 This is an inplace version of `setitem()`, mutating the manager/values
2228 in place, not returning a new Manager (and Block), and thus never changing
2229 the dtype.
2230 """
2231 if not self._has_no_reference(0):
2232 self.blocks = (self._block.copy(deep=True),)
2233 self._reset_cache()
2234
2235 arr = self.array
2236
2237 # EAs will do this validation in their own __setitem__ methods.
2238 if isinstance(arr, np.ndarray):
2239 # Note: checking for ndarray instead of np.dtype means we exclude
2240 # dt64/td64, which do their own validation.
2241 value = np_can_hold_element(arr.dtype, value)
2242
2243 if isinstance(value, np.ndarray) and value.ndim == 1 and len(value) == 1:
2244 # NumPy 1.25 deprecation: https://github.com/numpy/numpy/pull/10615
2245 value = value[0, ...]
2246
2247 arr[indexer] = value
2248
2249 def idelete(self, indexer) -> SingleBlockManager:
2250 """

Callers 2

_set_with_engineMethod · 0.80
column_setitemMethod · 0.80

Calls 4

_has_no_referenceMethod · 0.95
np_can_hold_elementFunction · 0.90
_reset_cacheMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected