I understand to replace a string in a column would simply be:
df['surf'].replace(to_replace='Grass', value='Turf')
This replaces all the values of 'Grass' with 'Turf' in my column. But I want the opposite of that. I've tried to look up using != or ~, but haven't gotten that to work.
What if I want all the values NOT 'Grass' to be replaced with 'Turf'
Edit: I should add, I can do it with:
df.loc[df['surf'] != 'Grass', 'surf'] = 'Turf'
but was wondering if there was a way with the .replace