I have a data frame like this:
df:
C1 C2
Ford 11
ram 13
SUV 19
SEDAN 14
I want to filter the data frame column C1 where the C1 values end with a upper case character. So the expected output looks like this:
C1 C2
SUV 19
SEDAN 14
I tried different regex approaches but nothing worked out for me.
Can anyone help me with this?
>Solution :
str.endswith doesn’t accept regexes, use str.contains:
df[df['C1'].str.contains('[A-Z]$')]
Output:
C1 C2
2 SUV 19
3 SEDAN 14