I'm learning python. I'm trying to identify rows of data where the string value includes a special character.
import pandas as pd
cn = pd.read_excel(f"../Files/df.xlsx", sheet_name='Values')
cn = cn[['DestinationName']]
special_characters = "!@#$%^&*()-+?_=,<>/"
cn['Special Characters'] = ["Y" if any(c in special_characters for c in cn) else "N"]
Basically, I'd like to either only display rows that include any of the special characters, or create a separate column to show whether Yes (it includes a special character) or No. For example, Red & Blue has the "&" character so it should be flagged as Yes, while RedBlue shouldn't.
I'm a little stuck, and any help would be appreciated