草庐IT

Virginia

全部标签

python - 在不预定义要使用的字符串数的情况下在 Pandas 中搜索多个字符串

我想知道是否有更通用的方法来执行以下操作?我想知道是否有办法创建st函数以便我可以搜索非预定义数量的字符串?例如,能够创建一个通用的st函数,然后键入st('Governor','Virginia','Google)这是我当前的函数,但它预定义了两个您可以使用的词。(df是一个Pandas数据框)defsearch(word1,word2,word3df):"""allowsyoutosearchanintersectionofthreeterms"""returndf[df.Name.str.contains(word1)&df.Name.str.contains(word2)&df