python – AssertionError:col应该是Column

python – AssertionError:col应该是Column,第1张

概述如何在PySpark中创建一个新列并使用今天的日期填充此列? 这是我试过的: import datetimenow = datetime.datetime.now()df = df.withColumn("date", str(now)[:10]) 我收到此错误: AssertionError: col should be Column How to create a new column i 如何在PySpark中创建一个新列并使用今天的日期填充此列?

这是我试过的:

import datetimeNow = datetime.datetime.Now()df = df.withColumn("date",str(Now)[:10])

我收到此错误:

AssertionError: col should be Column

解决方法

How to create a new column in PySpark and fill this column with the date of today?

已有功能:

from pyspark.sql.functions import current_datedf.withColumn("date",current_date().cast("string"))

AssertionError: col should be Column

使用文字

from pyspark.sql.functions import litdf.withColumn("date",lit(str(Now)[:10]))
总结

以上是内存溢出为你收集整理的python – AssertionError:col应该是Column全部内容,希望文章能够帮你解决python – AssertionError:col应该是Column所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1207146.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存