Reputation: 51
I want to replace dataframe column-specific value which start or ends with specific strings.
Like in below Dataframe I want to replace value with blanks if it contains specific eg.updated string in words
Dataframe
Sr no# |
---|
123 |
abcd |
NOTUPDATED |
notupdated |
Notupdated |
Updated |
joan aulia UPDATED |
nameUPDATED |
not |
Expected Output
Sr no# |
---|
123 |
abcd |
Updated |
not |
Upvotes: 1
Views: 160
Reputation: 863166
Use Series.str.contains
with regex with .+
for any value before updated
, $
for end of strings and case=False
for ignore cases:
df.loc[df['Sr no#'].str.contains(r'.+updated$', case=False), 'Sr no#'] = ''
Upvotes: 1