如何在Pyspark中取一列的字符串类型小数,然后将其围成最接近的50个值?
我在数据集中有一个列,称为“ x”:
x |
---|
“ 2893.324” |
“ 1058.112” |
“ 5651.324” |
im试图使这些数字是互插值,该数字是互插的值,圆形到最接近的50个
输出应为:
x | 结果 |
---|---|
“ 2893.324” | 2900“ 2900 |
” 1058.112“ 1058.112” 1058.112“ | 1050 |
“ 5651.324” | 5650 |
I have a column in a dataset called "X":
X |
---|
"2893.324" |
"1058.112" |
"5651.324" |
Im trying to make these numbers be interger values that round to nearest 50
Output should be this:
X | results |
---|---|
"2893.324" | 2900 |
"1058.112" | 1050 |
"5651.324" | 5650 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议除以50,舍入到最近的整数,然后再次繁殖。
无需用户定义的函数,
pyspark.sql.functions
模块已覆盖。请参阅建议的代码:I would suggest dividing by 50, rounding to nearest integer and then multiplying again.
no need for user-defined-functions,
pyspark.sql.functions
module has you covered. see suggested code: