I have two DataFrames df and df1. Thereby df gets daily new inputs via the cat_Id and gives the quality value. Df1 corresponds to a "catalog" that lists all Ids and outputs the name of the corresponding Id.
cat_id= [2,1,3]
begin_date = '2010-10-01'
quality = [35.9,69.1,0.0]
df = pd.DataFrame({'date':pd.date_range(begin_date, periods=len(cat_id)),'cat_id':cat_id,'quality':quality,})
AND:
category = ['A','B','C']
cat_id= [1,2,3]
df1 = pd.DataFrame({'category':category,'cat_id':cat_id})
So the Output looks like this:
df
date cat_id quality
0 2010-10-01 2 35.9
1 2010-10-02 1 69.1
2 2010-10-03 3 0.0
df1
category cat_id
0 A 1
1 B 2
2 C 3
I want to build a function that takes the value of each row of df['cat_id'] and goes through the catalog df1[cat_id] and then takes the associated name from df1[category].
So basically the Goal-Output should look like this:
date category quality
0 2010-10-01 B 35.9
1 2010-10-02 A 69.1
2 2010-10-03 C 0.0
Thanks for your help.