modin.pandas.Series.where¶
- Series.where(cond: DataFrame | Series | Callable | AnyArrayLike, other: DataFrame | Series | Callable | Scalar | None = nan, inplace: bool = False, axis: Axis | None = None, level: Level | None = None)[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.30.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/series_overrides.py#L1732-L1751)¶
- Replace values where the condition is False. - Parameters:
- cond – bool Series/DataFrame, array-like, or callable Where cond is True, keep the original value. Where False, replace with corresponding value from other. If cond is callable, it is computed on the Series/DataFrame and should return boolean Series/DataFrame or array. The callable must not change input Series/DataFrame (though pandas doesn’t check it). 
- other – scalar, Series/DataFrame, or callable Entries where cond is False are replaced with corresponding value from other. If other is callable, it is computed on the Series/DataFrame and should return scalar or Series/DataFrame. The callable must not change input Series/DataFrame (though pandas doesn’t check it). If not specified, entries will be filled with the corresponding NULL value (np.nan for numpy dtypes, pd.NA for extension dtypes). 
- inplace – bool, default False Whether to perform the operation in place on the data. 
- axis – int, default None Alignment axis if needed. For Series this parameter is unused and defaults to 0. 
- level – int, default None Alignment level if needed. 
 
- Returns:
- Same type as caller or None if inplace=True. 
 - Notes - The where method is an application of the if-then idiom. For each element in the calling DataFrame, if cond is True the element is used; otherwise the corresponding element from the DataFrame other is used. If the axis of other does not align with axis of cond Series/DataFrame, the misaligned index positions will be filled with False. - The signature for DataFrame.where() differs from numpy.where(). Roughly df1.where(m, df2) is equivalent to np.where(m, df1, df2). - For further details and examples see the where documentation in indexing. - The dtype of the object takes precedence. The fill value is casted to the object’s dtype, if this can be done losslessly. - Examples:: >>> s = pd.Series(range(5)) >>> s.where(s > 0) # doctest: +NORMALIZE_WHITESPACE 0 NaN 1 1.0 2 2.0 3 3.0 4 4.0 dtype: float64 - >>> s = pd.Series(range(5)) >>> t = pd.Series([True, False]) >>> s.where(t, 99) 0 0 1 99 2 99 3 99 4 99 dtype: int64 - >>> s.where(s > 1, 10) 0 10 1 10 2 2 3 3 4 4 dtype: int64