python - combine dataframes in pandas with repeat slices of one of them
问题描述
I want to combine 2 dataframes.
Here are the samples of dataframes:
df1:
df2:
Desired output should be:
What I want in essence is to extend df1 with data from df2. Key to linking data is index of both dataframes which is ['latitude','level','longitude']
. I want to omit data with index unique to df2. i.e. I don't want to see data with index [41, 1000, 19.25 ]
Any help is appreciated.
解决方案
Use "merge" with how='left', which omits indexes not in df1:
rslt= pd.merge(df1,df2,on=["latitude","level","longitude"],how="left")
推荐阅读
- snowflake-cloud-data-platform - Snowflake 是否支持带有 EXCEPT 运算符的 CTE
- c++ - 在 C++ 中使用 '=' 运算符使两个数组相等
- ruby-on-rails - 我如何使用acts_as_state_machine gem 验证与管理员帐户的预订
- asp.net-core-webapi - ASP.NET CORE Web API 中的路由
- r - ggplot2中的自定义重新排序直方图填充类别
- c# - 使用 C# 中的连续日期识别分层数据中的父级
- javascript - 路由通过foreach循环后的Jquery警报响应
- python-3.x - 规范化熊猫数据框
- swift - 根据在他的孩子中所做的更改更改 swiftUI 视图中的值
- javascript - 构建一个页面,该页面具有一个设置随机背景图像的按钮