0 votes
1 view
in Data Science by (17.6k points)

I have a dataframe(sample_emails) that provides a list of emails and I would like to extract only the workplace from the email. For example from the email such as [email protected], it should return only the string "uber". I tried writing the code for this but I keep getting a variety of errors.

extract_company = extract_company.find(email[ start['@', end['.']]

def extract_company(email):

    return

The extracted value should be returned into the df extract_company

1 Answer

0 votes
by (41.4k points)

Use this below line of code with pandas.Series.str.extract:

import pandas as pd

extract_company = pd.Series(['[email protected]', '[email protected]'])

extract_company.str.extract('@(.+)\.')

This will give you the output as: 

          0

0    google

1    facebook

If you wish to learn Pandas visit this Pandas Tutorial.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !

Categories

...