python - Python 等效于 select * from a where account_id in (select account_id from b)
问题描述
正如标题所示。我来自 SQL 背景,正在寻找最好的方法。
c = a.account_id.isin(b.account_id).astype(bool)
a[c]
以上是最有效的方法吗?
解决方案
是的,但是我们可以将它们放入 on row 中,并且您不需要将isin
输出转换为 bool,因为它已经是 bool 类型的数据
a[a.account_id.isin(b.account_id)]
推荐阅读
- flutter - 如何解决此错误“在构建期间调用 setState() 或 markNeedsBuild()。”?
- android - 如何使用 Kotlin 在 Android Studio 中创建意图数组对象
- google-apps-script - Chrome 83 版发布后,模态对话框中的文件下载不起作用
- audio - 添加水印时FFMPEG输出被截断
- java - 使用自定义存储库中的依赖项构建 JAR
- javascript - 下标标签在 HTML 选择标签中不起作用
- anaconda - 使用 conda 从特定通道安装包
- laravel - 下载不带标题的 xlsx 文件,Vuejs
- docker - 错误:不可满足的约束:Alpine Linux 中的流(缺失)
- sorting - 使用 NEST 7 进行 ElasticSearch 排序