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