Remove column final
, use left join with indicator
parameter, so is possible create 1,0
column by mapping True, False
by compare both
:
df = df2.drop('final', axis=1).merge(df1, how='left', indicator='final')
df['final'] = df['final'].eq('both').astype(int)
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.