捷徑

torcharrow.Column.filter

Column.filter(predicate: Union[Callable, Iterable], columns: Optional[List[str]] = None)

選取 predicate 為 True 的列。與 Pandas 不同。使用 keep 進行 Pandas 過濾。

參數:
  • predicate (callable 或 iterable) – 謂詞函式或與欄位長度相同的布林值迭代器。如果是 n 元謂詞,請使用 columns 參數提供引數。

  • columns (字串名稱列表) – 要使用哪些欄位來調用 filter。如果為 None,則套用至所有欄位。

  • None (預設值) – 要使用哪些欄位來調用 filter。如果為 None,則套用至所有欄位。

另請參閱

mapreduceflatmap

範例

>>> ta.column([1,2,3,4]).filter([True, False, True, False]) == ta.column([1,2,3,4]).filter(lambda x: x%2==1)
0  1
1  1
dtype: boolean, length: 2, null_count: 0

文件

取得 PyTorch 完整的開發者文件

查看文件

教學課程

取得適用於初學者和進階開發者的深入教學

查看教學

資源

尋找開發資源並獲得問題解答

查看資源