def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,<EOL>errors='<STR_LIT>', try_cast=False):
inplace = validate_bool_kwarg(inplace, '<STR_LIT>')<EOL>cond = com.apply_if_callable(cond, self)<EOL>if isinstance(cond, NDFrame):<EOL><INDENT>cond, _ = cond.align(self, join='<STR_LIT:right>', broadcast_axis=<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>if not hasattr(cond, '<STR_LIT>'):<EOL><INDENT>cond = np.asanyarray(cond)<EOL><DEDENT>if cond.shape != self.shape:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>cond = self._constructor(cond, **self._construct_axes_dict())<EOL><DEDENT>fill_value = bool(inplace)<EOL>cond = cond.fillna(fill_value)<EOL>msg = "<STR_LIT>"<EOL>if not isinstance(cond, pd.DataFrame):<EOL><INDENT>if not is_bool_dtype(cond):<EOL><INDENT>raise ValueError(msg.format(dtype=cond.dtype))<EOL><DEDENT><DEDENT>elif not cond.empty:<EOL><INDENT>for dt in cond.dtypes:<EOL><INDENT>if not is_bool_dtype(dt):<EOL><INDENT>raise ValueError(msg.format(dtype=dt))<EOL><DEDENT><DEDENT><DEDENT>cond = -cond if inplace else cond<EOL>try_quick = True<EOL>if hasattr(other, '<STR_LIT>'):<EOL><INDENT>if other.ndim <= self.ndim:<EOL><INDENT>_, other = self.align(other, join='<STR_LIT:left>', axis=axis,<EOL>level=level, fill_value=np.nan)<EOL>if (axis is None and<EOL>not all(other._get_axis(i).equals(ax)<EOL>for i, ax in enumerate(self.axes))):<EOL><INDENT>raise InvalidIndexError<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise NotImplementedError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if isinstance(other, np.ndarray):<EOL><INDENT>if other.shape != self.shape:<EOL><INDENT>if self.ndim == <NUM_LIT:1>:<EOL><INDENT>icond = cond.values<EOL>if len(other) == <NUM_LIT:1>:<EOL><INDENT>other = np.array(other[<NUM_LIT:0>])<EOL><DEDENT>elif len(cond[icond]) == len(other):<EOL><INDENT>if try_quick:<EOL><INDENT>try:<EOL><INDENT>new_other = com.values_from_object(self)<EOL>new_other = new_other.copy()<EOL>new_other[icond] = other<EOL>other = new_other<EOL><DEDENT>except Exception:<EOL><INDENT>try_quick = False<EOL><DEDENT><DEDENT>if not try_quick:<EOL><INDENT>dtype, fill_value = maybe_promote(other.dtype)<EOL>new_other = np.empty(len(icond), dtype=dtype)<EOL>new_other.fill(fill_value)<EOL>maybe_upcast_putmask(new_other, icond, other)<EOL>other = new_other<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>other = self._constructor(other, **self._construct_axes_dict())<EOL><DEDENT><DEDENT>if axis is None:<EOL><INDENT>axis = <NUM_LIT:0><EOL><DEDENT>if self.ndim == getattr(other, '<STR_LIT>', <NUM_LIT:0>):<EOL><INDENT>align = True<EOL><DEDENT>else:<EOL><INDENT>align = (self._get_axis_number(axis) == <NUM_LIT:1>)<EOL><DEDENT>block_axis = self._get_block_manager_axis(axis)<EOL>if inplace:<EOL><INDENT>self._check_inplace_setting(other)<EOL>new_data = self._data.putmask(mask=cond, new=other, align=align,<EOL>inplace=True, axis=block_axis,<EOL>transpose=self._AXIS_REVERSED)<EOL>self._update_inplace(new_data)<EOL><DEDENT>else:<EOL><INDENT>new_data = self._data.where(other=other, cond=cond, align=align,<EOL>errors=errors,<EOL>try_cast=try_cast, axis=block_axis,<EOL>transpose=self._AXIS_REVERSED)<EOL>return self._constructor(new_data).__finalize__(self)<EOL><DEDENT>
Equivalent to public method `where`, except that `other` is not
applied as a function even if callable. Used in __setitem__.