I have a dataframe (df) containing columns ['toaddress', 'ccaddress', 'body']
I want to iterate through the index of the dataframe to get the min, max, and average amount of email addresses in toaddress and ccaddress fields as determined by counting the instance of and '@' within each field in those two columns
If all else fails, i guess I could just use df.toaddress.str.contains(r'@').sum() and divide that by the number of rows in the data frame to get the average, but I think it's just counting the rows that at least have 1 @ sign.
df.toaddress.str.contains(r'@').sum()why not usedf.toaddress.str.count(r'@')if you're happy going column by column? I added an answer to do it across more than one column in one step.