我想过滤特定日期之前所有日期的数据集。特别是当前日期前一天。
我试过下面的代码:
df = df.filter(F.col('date') <= F.current_date() - 1)
但是我收到以下错误:
u"cannot resolve '(current_date() - 1)' due to data type mismatch: differing types in '(current_date() - 1)' (date and int)
F.date_sub
方法应该工作:
df.filter(F.col('date') <= F.date_sub(F.current_date(), 1))