Welcome to Qi-U Community for programmer and developer-Open, Learning and Share

Categories

0 votes
195 views
in Technique[技术] by (31.9m points)

pandas - Vlookup/Map value from one dataframe to another dataframe in Python

I want to do something similar to the vlookup in the python. Here is a dataframe I want to lookup for value 'Flow_Rate_Lupa'enter image description here

And here is the dataframe I want to fill the data by looking at the same month+day to fill the missing value. Is there any one to help me to solve how to do this QAQenter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (31.9m points)

I usually merge the two data frames and define an indicator, then filter out the values where the indicator says both meaning data is in both data frames.

import pandas as pd

mergedData= pd.merge(df1,df2, how='left' ,left_on='Key1', right_on='Key2', indicator ='Exists')
filteredData = mergedData[mergedData[Exists]='both']

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Qi-U Community for programmer and developer-Open, Learning and Share
...