I want to use .endswith()
or regexp in conditional subsetting of Sender name
column in my dataframe.
Dataframe df
has two columns Sender email
, Sender name
which I will use to define a subsetting rule, to select all mail coming from a specific shop and specific email of this shop:
df = df[(df["Sender name"]=="Shop_name"]) & (df["Sender email"]=="reply@shop.com")]
But then I figured out that there are also mails from
buy@shop.com
,noreply@shop.com
, etc. Is there an any way to neatly introduce all this mailboxes into something like*@shop.com
in the second condition?I tried using
endswith()
, but couldn't figure out how to make it work forseries
object. I figured out I may first form a list with all mails from the column, and then check if sending mailserver is in it withpd.Series.isin
. But maybe there is something more elegant out there?