我正在尝试在df2中查找一列,并且仅对df2列中存在的df1中的列求和。
const onSubmit = (data, e) => {
e.target.reset();
};
结果:
df1 =
London, New York, Paris, LA, Chicago
1000, 2000, 5000, 10000, 3000
df2 =
US Cities
New York
Miami
LA
Chicago
Seattle
答案 0 :(得分:2)
您在这里:
df1['Sum of US Cities'] = df1.loc[:, df1.columns.isin(df2['US Cities'])].sum(axis=1)
输出
London New York Paris LA Chicago Sum of US Cities
0 1000 2000 5000 10000 3000 15000