运行 ❯
获取您自己的
Python
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
import pandas as pd data1 = { "name": ["Sally", "Mary", "John"], "age": [50, 40, 30] } data2 = { "name": ["Sally", "Peter", "Micky"], "age": [77, 44, 22] } df1 = pd.DataFrame(data1) df2 = pd.DataFrame(data2) newdf = df1.merge(df2, how='right') print(newdf)
name age 0 Sally 77 1 Peter 44 2 Micky 22