I have 4 data frames as per below
df = pd.DataFrame({_id:[1,2,3,4], name:[Charan, Kumar, Nikhil, Kumar], })
df1 = pd.DataFrame({_id:[1,3,4], count_of_apple:[5,3,1]})
df2 = pd.DataFrame({_id:[1,2,3], count_of_organge:[8,4,6]})
df3 = pd.DataFrame({_id:[2,3,4], count_of_lime:[7,9,2]})
I want to merge all the data frames to a single data frame called a final
I have tried using PD.merge but the problem with it is I have to do it 3 different times is there a simpler way of doing it?
I used the below code to get the result
final = pd.merge(df, df1, on='_id', how='left')
final = pd.merge(final, df2, on='_id', how='left')
final = pd.merge(final, df3, on='_id', how='left')
I would want the final result to be something like this
final.head()
_id | name | count of orange | count of apple | count of lime
1 | Charan | 5 | 8 | Na
2 | Kumar | Na | 4 | 7
3 | Nikhil | 3 | 6 | 9
4 | Kumar | 1 | Na | 2

