(
condition: T_ExtensionArray | np.typing.ArrayLike,
x: T_ExtensionArray,
y: T_ExtensionArray | np.typing.ArrayLike,
)
| 187 | |
| 188 | @implements(np.where) |
| 189 | def __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 | |
| 201 | def _replace_duck(args, replacer: Callable[[PandasExtensionArray], Any]) -> list: |
nothing calls this directly
no test coverage detected
searching dependent graphs…