用法:
Series.isin(values)
Series 中的元素是否包含在
values
中。此文檔字符串是從 pandas.core.series.Series.isin 複製而來的。
可能存在與 Dask 版本的一些不一致之處。
返回一個布爾係列,顯示係列中的每個元素是否與傳遞的
values
序列中的元素完全匹配。- values:設置或list-like
要測試的值序列。傳入單個字符串將引發
TypeError
。相反,將單個字符串轉換為一個元素的列表。
- Series
一係列布爾值,指示每個元素是否在值中。
- TypeError
- 如果
values
是一個字符串
- 如果
參數:
返回:
拋出:
例子:
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama', ... 'hippo'], name='animal') >>> s.isin(['cow', 'lama']) 0 True 1 True 2 True 3 False 4 True 5 False Name: animal, dtype: bool
要反轉布爾值,請使用
~
運算符:>>> ~s.isin(['cow', 'lama']) 0 False 1 False 2 False 3 True 4 False 5 True Name: animal, dtype: bool
將單個字符串作為
s.isin('lama')
傳遞將引發錯誤。改為使用一個元素的列表:>>> s.isin(['lama']) 0 True 1 False 2 True 3 False 4 True 5 False Name: animal, dtype: bool
字符串和整數是不同的,因此不可比較:
>>> pd.Series([1]).isin(['1']) 0 False dtype: bool >>> pd.Series([1.1]).isin(['1.1']) 0 False dtype: bool
相關用法
- Python dask.dataframe.Series.isnull用法及代碼示例
- Python dask.dataframe.Series.isna用法及代碼示例
- Python dask.dataframe.Series.idxmin用法及代碼示例
- Python dask.dataframe.Series.iteritems用法及代碼示例
- Python dask.dataframe.Series.idxmax用法及代碼示例
- Python dask.dataframe.Series.apply用法及代碼示例
- Python dask.dataframe.Series.clip用法及代碼示例
- Python dask.dataframe.Series.prod用法及代碼示例
- Python dask.dataframe.Series.fillna用法及代碼示例
- Python dask.dataframe.Series.to_frame用法及代碼示例
- Python dask.dataframe.Series.sum用法及代碼示例
- Python dask.dataframe.Series.dropna用法及代碼示例
- Python dask.dataframe.Series.gt用法及代碼示例
- Python dask.dataframe.Series.ge用法及代碼示例
- Python dask.dataframe.Series.repartition用法及代碼示例
- Python dask.dataframe.Series.mod用法及代碼示例
- Python dask.dataframe.Series.count用法及代碼示例
- Python dask.dataframe.Series.append用法及代碼示例
- Python dask.dataframe.Series.add用法及代碼示例
- Python dask.dataframe.Series.pow用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 dask.dataframe.Series.isin。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。