def setitem(self, indexer, value):
<EOL>if value is None:<EOL><INDENT>if self.is_numeric:<EOL><INDENT>value = np.nan<EOL><DEDENT><DEDENT>values = self.values<EOL>try:<EOL><INDENT>values, value = self._try_coerce_args(values, value)<EOL>if hasattr(value, '<STR_LIT>') and is_dtype_equal(values.dtype,<EOL>value.dtype):<EOL><INDENT>dtype = self.dtype<EOL><DEDENT>else:<EOL><INDENT>dtype = '<STR_LIT>'<EOL><DEDENT><DEDENT>except (TypeError, ValueError):<EOL><INDENT>find_dtype = False<EOL>if hasattr(value, '<STR_LIT>'):<EOL><INDENT>dtype = value.dtype<EOL>find_dtype = True<EOL><DEDENT>elif lib.is_scalar(value):<EOL><INDENT>if isna(value):<EOL><INDENT>dtype = False<EOL><DEDENT>else:<EOL><INDENT>dtype, _ = infer_dtype_from_scalar(value,<EOL>pandas_dtype=True)<EOL>find_dtype = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>dtype = '<STR_LIT>'<EOL><DEDENT>if find_dtype:<EOL><INDENT>dtype = find_common_type([values.dtype, dtype])<EOL>if not is_dtype_equal(self.dtype, dtype):<EOL><INDENT>b = self.astype(dtype)<EOL>return b.setitem(indexer, value)<EOL><DEDENT><DEDENT><DEDENT>arr_value = np.array(value)<EOL>if not self._can_hold_element(value):<EOL><INDENT>dtype, _ = maybe_promote(arr_value.dtype)<EOL>values = values.astype(dtype)<EOL><DEDENT>transf = (lambda x: x.T) if self.ndim == <NUM_LIT:2> else (lambda x: x)<EOL>values = transf(values)<EOL>check_setitem_lengths(indexer, value, values)<EOL>def _is_scalar_indexer(indexer):<EOL><INDENT>if arr_value.ndim == <NUM_LIT:1>:<EOL><INDENT>if not isinstance(indexer, tuple):<EOL><INDENT>indexer = tuple([indexer])<EOL>return any(isinstance(idx, np.ndarray) and len(idx) == <NUM_LIT:0><EOL>for idx in indexer)<EOL><DEDENT><DEDENT>return False<EOL><DEDENT>def _is_empty_indexer(indexer):<EOL><INDENT>if is_list_like(indexer) and not len(indexer):<EOL><INDENT>return True<EOL><DEDENT>if arr_value.ndim == <NUM_LIT:1>:<EOL><INDENT>if not isinstance(indexer, tuple):<EOL><INDENT>indexer = tuple([indexer])<EOL><DEDENT>return any(isinstance(idx, np.ndarray) and len(idx) == <NUM_LIT:0><EOL>for idx in indexer)<EOL><DEDENT>return False<EOL><DEDENT>if _is_empty_indexer(indexer):<EOL><INDENT>pass<EOL><DEDENT>elif _is_scalar_indexer(indexer):<EOL><INDENT>values[indexer] = value<EOL><DEDENT>elif (len(arr_value.shape) and<EOL>arr_value.shape[<NUM_LIT:0>] == values.shape[<NUM_LIT:0>] and<EOL>np.prod(arr_value.shape) == np.prod(values.shape)):<EOL><INDENT>values[indexer] = value<EOL>try:<EOL><INDENT>values = values.astype(arr_value.dtype)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>values[indexer] = value<EOL><DEDENT>values = self._try_coerce_and_cast_result(values, dtype)<EOL>block = self.make_block(transf(values))<EOL>return block<EOL>
Set the value inplace, returning a a maybe different typed block.

        Parameters
        ----------
        indexer : tuple, list-like, array-like, slice
            The subset of self.values to set
        value : object
            The value being set

        Returns
        -------
        Block

        Notes
        -----
        `indexer` is a direct slice/positional indexer. `value` must
        be a compatible shape.