【发布时间】:2022-01-24 14:46:42
【问题描述】:
我有这个功能
def dec(x):
"""Convert to Decimal and remove exponent and trailing zeros"""
if not x:
return Decimal(0)
if not isinstance(x, Decimal):
x = Decimal(str(x))
return x.quantize(Decimal(1)) if x == x.to_integral() else x.normalize()
在熊猫中我会这样做
df['price'].apply(dec)
但是,dask 不支持这一点,那么将列转换为十进制类型的另一种方法是什么?
【问题讨论】:
-
这里已经回答了这个问题:参考this
标签: python python-3.x decimal dask dask-dataframe