'How to combine two dataframes into one like this, using pandas and python?

Please see the picture here.

I have two data frames and i need to convert it into single one, using merge or concat method and i am unable to do so. Can our community please help me doing this ?



Solution 1:[1]

import pandas as pd
df1 = pd.DataFrame.from_dict({'A':[1,2,2,3]})
df2 = pd.DataFrame.from_dict({'A':[1,2,3], 'B':['x', 'y', 'z']})

df1.merge(df2, how='left')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex