1

I have a dataframe of email addresses, and I want to search which are the most used email providers (eg. gmail.com, yahoo.com etc). I used the following code

dfEmail=Ecom['Email']

I have the following data

0                    [email protected]

1                   [email protected]

2       [email protected]

3          [email protected]

4          [email protected]

...              

9995            [email protected]

9996                [email protected]

9997                 [email protected]

9998           [email protected]

9999             [email protected]

Name: Email, Length: 10000, dtype: object

I want to split these email addresses at "@" and get only names of email providers.

I tried the following

dfEmailSplit=dfEmail.str.split('@')
dfEmailSplit[500][1]

this gave me the following result:

'gmail.com'

How do i do this for all the email addresses?

anky
  • 74,114
  • 11
  • 41
  • 70

1 Answers1

1
import pandas as pd     
df = pd.DataFrame() 
data = {'email':['[email protected]', '[email protected]', 'amymiller@morales- harrison.com']} 
df = pd.DataFrame(data) 
tlds = {'tlds': [x.split('@')[1] for x in df['email']]}
df = pd.DataFrame(tlds)  
print(df) 
Seyi Daniel
  • 2,259
  • 2
  • 8
  • 18
  • Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Aug 22 '20 at 10:12
  • @MarkRotteveel: Noted. Thanks. – Seyi Daniel Aug 22 '20 at 10:16