xorbits.pandas.Index.where#

final Index.where(cond, other=None) pandas.core.indexes.base.Index[源代码]#

Replace values where the condition is False.

The replacement is taken from other.

参数
  • cond (bool array-like with the same length as self) – Condition to select the values on.

  • other (scalar, or array-like, default None) – Replacement if the condition is False.

返回

A copy of self with values replaced from other where the condition is False.

返回类型

pandas.Index

参见

Series.where

Same method for Series.

DataFrame.where

Same method for DataFrame.

实际案例

>>> idx = pd.Index(['car', 'bike', 'train', 'tractor'])  
>>> idx  
Index(['car', 'bike', 'train', 'tractor'], dtype='object')
>>> idx.where(idx.isin(['car', 'train']), 'other')  
Index(['car', 'other', 'train', 'other'], dtype='object')

警告

This method has not been implemented yet. Xorbits will try to execute it with pandas.

This docstring was copied from pandas.core.indexes.base.Index.