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