用法:
Series.where(cond, other=None, inplace=False)
替换条件为 False 的值。
- cond:布尔系列/数据帧,array-like
如果 cond 为 True,则保留原始值。如果为 False,则替换为其他对应的值。不支持可调用对象。
- other: scalar, list of scalars, Series/DataFrame:
cond 为 False 的条目将替换为来自 other 的相应值。不支持可调用对象。默认为无。
DataFrame 只需要标量或数组,如标量或与 self 具有相同维度的 DataFrame 。
系列只需要标量或具有相同长度的系列
- inplace:布尔值,默认为 False
是否对数据执行就地操作。
- 与调用者类型相同
参数:
返回:
例子:
>>> import cudf >>> df = cudf.DataFrame({"A":[1, 4, 5], "B":[3, 5, 8]}) >>> df.where(df % 2 == 0, [-1, -1]) A B 0 -1 -1 1 4 -1 2 -1 8
>>> ser = cudf.Series([4, 3, 2, 1, 0]) >>> ser.where(ser > 2, 10) 0 4 1 3 2 10 3 10 4 10 dtype: int64 >>> ser.where(ser > 2) 0 4 1 3 2 <NA> 3 <NA> 4 <NA> dtype: int64
相关用法
- Python cudf.Series.ceil用法及代码示例
- Python cudf.Series.update用法及代码示例
- Python cudf.Series.max用法及代码示例
- Python cudf.Series.head用法及代码示例
- Python cudf.Series.reindex用法及代码示例
- Python cudf.Series.interleave_columns用法及代码示例
- Python cudf.Series.min用法及代码示例
- Python cudf.Series.nlargest用法及代码示例
- Python cudf.Series.to_frame用法及代码示例
- Python cudf.Series.mask用法及代码示例
- Python cudf.Series.notnull用法及代码示例
- Python cudf.Series.isnull用法及代码示例
- Python cudf.Series.rmod用法及代码示例
- Python cudf.Series.map用法及代码示例
- Python cudf.Series.nsmallest用法及代码示例
- Python cudf.Series.data用法及代码示例
- Python cudf.Series.lt用法及代码示例
- Python cudf.Series.product用法及代码示例
- Python cudf.Series.add用法及代码示例
- Python cudf.Series.apply用法及代码示例
注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.Series.where。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。