I have a pandas data frame which looks like this
Name | Index1 | Index2 |
---|---|---|
AAA | 67 | 70 |
Aaa | 55 | 80 |
Abb | 32 | 20 |
BBB | 84 | 45 |
Baa | 80 | 70 |
Bbb | 13 | 40 |
where some rows have names with all uppercase
and some with lowercase
. How can i create another dataframe with only the uppercase rows
expected output will be :
Name | Index1 | Index2 |
---|---|---|
AAA | 67 | 70 |
BBB | 84 | 45 |
CodePudding user response:
Use isupper
from pandas:
df = df.loc[df["Name"].str.isupper(), :]
CodePudding user response:
same as above, without using loc
>>> df=pd.DataFrame(['AAA','Aaa','BBB','Bbb'],columns=['test'])
>>> df[df.test.str.isupper()==True]
test
0 AAA
2 BBB