torcharrow.if_else¶
- torcharrow.if_else(cond: Column, left: Column, right: Column)¶
返回一个列,其中每个元素都从 left 列或 righ 列中选择,具体取决于 cond 列中对应位置的值。
示例
>>> 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