python - How to get indices list for rows starting with lower case letter?
问题描述
I have a dataframe with one of the columns being df['Names']. How can I locate all the rows whose names start with a lower case letter?
col1 Names
1564 abby
2289 Barry
etc.
I'm trying to accomplish this using regex with no luck.
解决方案
one way from str.lower
df[df.Names.str[0]==df.Names.str[0].str.lower()]
Out[173]:
col1 Names
0 1564 abby
Another way islower
df[df.Names.str[0].str.islower()]
Out[174]:
col1 Names
0 1564 abby
推荐阅读
- javascript - 在 sequelize 中使用另一个表连接两个表
- c - C程序将十进制数转换为二进制字符串
- if-statement - How to merge two files based on data in multiple columns?
- reactjs - 如何使用 FormattedMessage 翻译 MaterialTable reactjs 的 searchPlaceholder
- python - 为什么在 models.py 中使用 django BooleanField 会导致 TypeError?
- python - Django枚举我相关的多对多对象
- legend - 当值右对齐时,Amcharts4 图例标签不会被截断
- android - 为 560dpi 和 420dpi 设备生成 Android 密度拆分
- bash - 如何从file.txt unix中提取变量
- c++ - 向量为空时显示消息