Я хотел бы проверить пару вариантов и посмотреть, есть ли один из них в другом списке. Я могу проверить, есть ли каждая серия отдельно в списке, но тогда я не знаю, как сказать что-то вроде if x in list or y in list, then return True
t1 = pd.Series(['A','B','C'],name='t1')
t2 = pd.Series(['E','F','G'],name = 't2')
test = pd.concat([t1,t2],axis=1)
include = ['A','F']
# create new column Included as
test["Included"] =
Моя первая идея (которая не работает):
test['t1inc'] = test['t1'].isin(include)
test['t2inc'] = test['t1'].isin(include)
test['Included'] = ["Y" if x == True or y == True else "N" for x,y in test['t1inc'],test['t2inc']]
Желаемый вывод:
print(test)
t1 t2 Included
0 A E True
1 B F True
2 C G False