Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Index.where#

finalIndex.where(cond,other=None)[source]#

Replace values where the condition is False.

The replacement is taken from other.

Parameters:
condbool array-like with the same length as self

Condition to select the values on.

otherscalar, or array-like, default None

Replacement if the condition is False.

Returns:
pandas.Index

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

See also

Series.where

Same method for Series.

DataFrame.where

Same method for DataFrame.

Examples

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

[8]ページ先頭

©2009-2025 Movatter.jp