擅长:python、mysql、java
<p>有一种可能的方法:</p>
<pre><code>def match_consumption(r):
if (r['creature'] in r['consumption']) and (r['food'] in r['consumption']):
return True
else:
return False
df['match'] = df.apply(match_consumption, axis=1)
df
consumption creature food match
0 squirrel eats apple squirrel apple True
1 monkey eats apple badger apple False
2 monkey eats banana monkey banana True
3 badger eats banana elephant banana False
</code></pre>