Ensures new columns (which go into the BlockManager as new blocks) are always copied (or a reference is being tracked to them under CoW) and converted into an array. Parameters ---------- value : scalar, Series, or array-like Returns
(self, value)
| 5730 | return data |
| 5731 | |
| 5732 | def _sanitize_column(self, value) -> tuple[ArrayLike, BlockValuesRefs | None]: |
| 5733 | """ |
| 5734 | Ensures new columns (which go into the BlockManager as new blocks) are |
| 5735 | always copied (or a reference is being tracked to them under CoW) |
| 5736 | and converted into an array. |
| 5737 | |
| 5738 | Parameters |
| 5739 | ---------- |
| 5740 | value : scalar, Series, or array-like |
| 5741 | |
| 5742 | Returns |
| 5743 | ------- |
| 5744 | tuple of numpy.ndarray or ExtensionArray and optional BlockValuesRefs |
| 5745 | """ |
| 5746 | self._ensure_valid_index(value) |
| 5747 | |
| 5748 | # Using a DataFrame would mean coercing values to one dtype |
| 5749 | assert not isinstance(value, DataFrame) |
| 5750 | if is_dict_like(value): |
| 5751 | if not isinstance(value, Series): |
| 5752 | value = Series(value) |
| 5753 | return _reindex_for_setitem(value, self.index) |
| 5754 | |
| 5755 | if is_list_like(value): |
| 5756 | com.require_length_match(value, self.index) |
| 5757 | return sanitize_array(value, self.index, copy=True, allow_2d=True), None |
| 5758 | |
| 5759 | @property |
| 5760 | def _series(self): |
no test coverage detected