python-3.x - 在 python pandas 中,如何使用 where 条件使用外连接?
问题描述
表格1
S.No BusNo Timings People
1 1234 3:05 pm 55
2 3456 3:30 pm 45
3 8945 3:45 pm 50
Table 2
BusNo Model
1234 Leyland
3456 Viking
使用 pandas 加入此表的条件:busno model people count for people between 50 and 55 and group by model
预期输出:
表3
S.No BusNo Timings People Model
1 1234 3:05 pm 55 Leyland
3 8945 3:45 pm 50 Nan
解决方案
我认为你需要pd.merge和pd.Series.between,
df=pd.merge(df1,df2,on='BusNo',how='outer')
df.loc[df['People'].between(50,55,inclusive=True),:]
推荐阅读
- asp.net-mvc - 如何在服务器端联系 Microsoft Access
- sql - 在 Biztalk 中使用 WCF-SQL 适配器上的模板消息体将提升的属性插入 SQL 数据库
- wso2 - WSO2SP 作为 APIM 和 EI 的分析
- ios - ios - 存在自定义类时模块字段为空
- android - 使用 Cordova 开发的 Android 应用程序可以离线工作吗?
- powerbi - Power BI - 给定日期的 2 个表的加权平均收益率
- c++ - 在类方法之外返回共享指针引用中断
- c++ - lambda 中的嵌套 std::bind 不能转换为 std::function(来自 void*)
- python - 如何在使用 pyspark shell 时导入额外的 python 包
- python - 如何在 AutoMLConfig 中将参数传递给 get_data 脚本