【发布时间】:2020-11-27 17:05:43
【问题描述】:
我正在尝试使用 databricks 中的 round() 函数将一些浮点值四舍五入为 2 位。但是,databricks python 不能像普通 python 那样工作。
如果有的话,请帮助我解释原因和解决方案。
lis = [-12.1334, 12.23433, 1.2343, -104.444]
lis2 = [round(val,2) for val in lis]
print(lis2)
TypeError: Invalid argument, not a string or column: -12.1334 of type <type 'float'>. For column literals, use 'lit', 'array', 'struct' or 'create_map' function.
【问题讨论】:
-
此代码不会产生声称的错误。请发布您的真实代码。
-
也无法重现错误
-
为了方便添加了图片证明
-
另外,代码必须在数据块笔记本中运行,而不是普通的 python 方式。正常的python方式将运行没有任何错误。问题在于基于数据块的 python。
标签: python databricks