简体   繁体   中英

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?

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM