My code worked on a previous dataset and now stopped working. I looked through other answers for this error message, but none seems applicable to mine.
I have one column in my dataframe df for Email_Address and I would like to just split the domain out into a new columns.
My dataframe is a subset of a previous df.
#create new df, for only email addresses I need to review
df = df_raw.loc[df_raw['Review'] == 'Y'].copy()
#I reset the index to fix the problem, but it didnt help
df = df.reset_index(drop=True)
#ensure Email Address is a string
df['Email_Address']= df.Email_Address.apply(str)
#make Email Address lower case
df['email_lowercase'] = df['Email_Address'].str.lower()
#Split out domain into a new column
df['domain'] = df['email_lowercase'].apply(lambda x: x.split('@')[1])
IndexError: list index out of range
@doesn't exist in one of your cell so that you can't access the part of the email that is 'after' the@. Sometimes users typeatinstead of@so they can't be traced by bots. Have you checked for that?df['Email_Address']= df.Email_Address.apply(str)to thisdf['Email_Address']= df.Email_Address.astype(str)Its also possible you have non-clean data where there is no data on some rows after@which would cause it to fail. Check that too.df, it's impossible to reproduce your error. Please provide a MVCE