python - 如何检查 Pyspark 中的计数值?
问题描述
我正在尝试创建一个查询,该查询将允许我获取一个表,其中 id 将出现至少 3 个计数,并且这些 id 在 k 列中的值为 0、3、4。
+---+---+
| i| k|
+---+---+
| 1 | 0|
| 1 | 3|
| 1 | 4|
| 2 | 0|
| 2 | 3|
| 2 | 3|
+---+---+
我想要的输出是:
+---+---+
| i| k|
+---+---+
| 1 | 0|
+---+---+
| 1 | 3|
+---+---+
| 1 | 4|
+---+---+
这是目前我的代码。但它只显示了一个 id 出现 3 次的表,我不确定如何检查这些计数中至少有 1 个是 0、3 还是 4
sample= sample.join(
sample.groupBy('i').count().where(('count == 3')).drop('count'), on=['i']
)
解决方案
推荐阅读
- node.js - 将 MERN 应用程序部署到 Namecheap 的 cPanel 以进行网络托管时遇到问题
- javascript - 如何使用 AWS CDK 为带有别名的 Lambda 设置 EventBridge 规则目标
- r - 如何比较两个可变和不同长度的数据帧以将一个数据帧的值添加到另一个数据帧,在必要时重复值
- ionic4 - Intranet 上的 Ionic 4 Web 项目
- javascript - Keycloak 内省端点
- angular - 类型'可观察的
' 不可分配给类型 'Observable ' - python - python psycopg2选择时区的current_timestamp问题
- django - NoReverseMatch 在 /property/city/city/
- python - 如何将 TF Dense 层转换为 PyTorch?
- docker - sh: curl: not found 甚至在 k8s pod 中安装 curl