Filtering DataFrame Columns with EndsWith, StartsWith, and Contains
Python
1| #Only keep rows where the text_column string ends with 'xy' 2| df = df[df['text_column'].str.endswith('xy')] 3| 4| #Only keep rows where the text_column string starts with 'test' 5| df = df[df['text_column'].str.startswith('test')] 6| 7| #Only keep rows where the text_column string contains 'ID' 8| df = df[df['text_column'].str.contains('ID')]
149
132
127
119