python - Pyspark - Selecting rows in dataframe based on values that exist in another dataframe
问题描述
Assume these two pyspark dataframes
:
dfA
id
1
2
3
4
dfB
src,dst
2 ,3
1 ,3
3 ,4
4 ,1
7 ,3
1 ,8
How can I get this desired output:
resultDf
src,dst
2 ,3
1 ,3
3 ,4
4 ,1
Basically I want to select Rows
from dfB
that contain a value of dfA
解决方案
我能够使用spark.sql
resultDf = spark.sql("SELECT * FROM dfA WHERE dfB.src IN (SELECT * FROM dfA) AND dfB.dst IN (SELECT * FROM dfA)")
推荐阅读
- python - Set numpy array values through list comprehension
- c++ - 在另一个应用程序窗口顶部绘制边框
- python - 如何确保我的 yaml 文件中没有空值
- vba - 在使用 VBA 发送电子邮件之前检查附件
- r - 从业务对象中读取 r 中的 xls 文件
- vuejs2 - VueJS中的v-for,如何跟踪以前的组件数据?
- java - Toast 适用于 Java 活动,但不适用于 kotlin
- javascript - 用于防止与模式匹配的导入的 ESLint 规则
- python - utils 文件中字典中的 NameError
- python - 在 Python 循环中查找第一个数字索引?