MCPcopy Index your code
hub / github.com/pydata/xarray / __extension_duck_array__where

Function __extension_duck_array__where

xarray/core/extension_array.py:189–198  ·  view source on GitHub ↗
(
    condition: T_ExtensionArray | np.typing.ArrayLike,
    x: T_ExtensionArray,
    y: T_ExtensionArray | np.typing.ArrayLike,
)

Source from the content-addressed store, hash-verified

187
188@implements(np.where)
189def __extension_duck_array__where(
190 condition: T_ExtensionArray | np.typing.ArrayLike,
191 x: T_ExtensionArray,
192 y: T_ExtensionArray | np.typing.ArrayLike,
193) -> T_ExtensionArray:
194 # pd.where won't broadcast 0-dim arrays across a scalar-like series; scalar y's must be preserved
195 if hasattr(y, "shape") and len(y.shape) == 1 and y.shape[0] == 1:
196 y = y[0] # type: ignore[index]
197 # pandas-stubs has strict overloads for Series.where that don't cover all valid arg types
198 return cast(T_ExtensionArray, pd.Series(x).where(condition, y).array) # type: ignore[call-overload]
199
200
201def _replace_duck(args, replacer: Callable[[PandasExtensionArray], Any]) -> list:

Callers

nothing calls this directly

Calls 1

whereMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…