我想验证df2 ['id']中是否存在df1 ['id'],我加上df1 ['new'] = 1否则df1 ['new'] = 0。
我该怎么办?
d = {'id': ['12', '13','77','22','777777','23'],'text':['tt','ey', 'ab','aa','xxx','xx']}
df1 = pd.DataFrame(data=d)
d = {'id': ['12', '17','13','22']}
df2 = pd.DataFrame(data=d)
#######Expected_output################
d = {'id': ['12', '13','77','22','777777','23'],'text':['tt','ey', 'ab','aa','xxx','xx'],'New' = [1,1,0,1,0,0]}
df1 = pd.DataFrame(data=d)