python - PySpark where 子句条件条件
问题描述
我在以下查询中收到语法错误:
df_result = df_checkout.join(df_checkin,
(
(df_checkout.product == df_checkin.product)
(df_checkout.host == df_checkin.host)
),
how = 'full_outer').where(df_checkout.rank =
F.when(((df_checkout.rank = df_checkin.rank) and (F.unix_timestamp(df_checkout.checkout_date, 'MM/dd/YYYY HH:MI:SS') <= F.unix_timestamp(df_checkin.checkin_date, 'MM/dd/YYYY HH:MI:SS'))), (df_checkin.rank - 1)).when(((df_checkout.rank = df_checkin.rank) and (F.unix_timestamp(df_checkout.checkout_date, 'MM/dd/YYYY HH:MI:SS') >= F.unix_timestamp(df_checkin.checkin_date, 'MM/dd/YYYY HH:MI:SS'))), df_checkin.rank).otherwise(None)
)
我有什么错误?
解决方案
你有一个=
而不是==
:
(df_checkout.rank = df_checkin.rank)
应该
(df_checkout.rank == df_checkin.rank)
推荐阅读
- css - CSS Grid - grid-gap 导致容器变得太小
- c - UNIX 域套接字 (PF_UNIX) 上的 send() 失败并出现 ENOBUFS 错误
- azure - Azure 搜索未缩放
- python - 使用 os rename 根据 python 中的变量重命名文件
- python - 从烧瓶中的用户那里获取正确的 IP 地址
- reactjs - Bootstrap 切换(导航栏)在第一次加载 React 时不起作用
- apache-spark - 与火花组混淆
- javascript - 我应该编译到哪个版本的 JavaScript?
- r - 使用 apply 函数将选定的列从 POSIXct 转换为具有特定格式的 Date
- javascript - html 文件未与 react-native 正确链接/执行