捷徑

torcharrow.if_else

torcharrow.if_else(cond: Column, left: Column, right: Column)

根據 cond 欄位中對應位置的值,從 left 欄位或 right 欄位選擇元素,並返回一個由這些元素組成的欄位。

範例

>>> import torcharrow as ta
>>> cond = ta.column([True, False, True, False])
>>> left = ta.column(["a1", "a2", "a3", "a4"])
>>> right = ta.column(["b1", "b2", "b3", "b4"])
>>> ta.if_else(cond, left, right)
0  'a1'
1  'b2'
2  'a3'
3  'b4'
dtype: string, length: 4, null_count: 0, device: cpu

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學課程

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

檢視教學課程

資源

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

檢視資源