Assuming a dataframe
Market | Status | Team |
-------|--------|------|
Chicago| 1 | Tom |
Chicago| 1 | Tom |
SF Bay | 3 | Julia|
SF Bay | 1 | Julia|
SF Bay | 1 | Julia|
And a dictionary
Team = {"Tom": "[email protected]", "Julia": "[email protected]", "Carol": "[email protected]"}
I want to get each team members specific dataframe, convert it to HTML and email it to them. I can get the dataframes individually that I need and then df.to_html() it. In the case above, Carol is in the dictionary, but not within the dataframe, so I don't want her to receive an email.
I've tried
for i in Team:
df[df['Team'].str.contains(i)]
Mail = df[df['Team'].isin([i])]
...
#send an email
But this would then send an email with a blank dataframe to Carol. How can I iterate through easily and get only those names that are present from my dictionary and then utilize the dictionary email value to send an email?