Let's say I have this example Series ser:
ser = pd.Series(["gmail", "yahoo", "office"])
and the following string: t = "mail@mail.com"
I want to check if any of the values in the Series is a substring of the string t.
For the other way around it's very easy (ser.str.contains(t)), but what's an efficant way to do my way?
Thanks
这将做到:
any(s in t for s in ser)
您可以使用any
或all
:
any(x in t for x in ser)
all(x in t for x in ser)
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.