0

我试图在将浮动列转换为字符串列之前检查它是否实际上是一个 int 列(确切的用例:123.00 需要为 123,'123-4' 需要保持为 '123-4')。

代码:

    # series: modin pandas Series
    try:
        # If it's a int (123.0)
        return series.astype(int).astype(str)
    except Exception:
        # If it's a string (12-3)
        return series.astype(str)

但是,没有捕获到异常

ValueError:int() 的无效文字,基数为 10:'123-4'

ray.exceptions.RayTaskError(ValueError): ray::apply_func()

我试过用except:, except ValueError:,

from ray.exceptions import RayTaskError
except RayTaskError:

更新:作为 github 问题呈现:https ://github.com/modin-project/modin/issues/3966

4

0 回答 0