Jul-20-2020, 01:46 AM
You don't need to use pure for-loop here,
# the number of rows where your condition is True true_cnt = (df['Type of breach']!='HACK') & (df['Description of incident'].str.contains('bank account', na=False) | df['Description of incident'].str.contains('social security number', na=False)).sum() # The number of rows in df (Total) len(df) # Probably, you need this: len(df) - true_cnt