且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Pyspark中的日期列中减去日期列?

更新时间:2023-11-29 14:17:34

我能够使用selectExpr解决此问题.

I was able to solve this using selectExpr.

df.selectExpr('date_sub(date_col, day_col) as subtracted_dates')

如果要将列添加到原始DF,只需在表达式中添加*

If you want to append the column to the original DF, just add * to the expression

df.selectExpr('*', 'date_sub(date_col, day_col) as subtracted_dates')