检查串联中的最后一个字符是否为上案,如果是的,则转换为小写
我有一列的字符串看起来与以下几个相似:
1 IX-1-a
2 IX-1-b
3 IX-1-C
4 IX-1-D
有些以小写字母结尾,而另一些则以大写结尾。我需要标准化所有结尾以小写,而不会在字符串开始时影响字母。以下是我正在使用的一些代码片段,以在该系列中进行更改,但这并不是很可行。
if i in tw4515['Unnamed: 0'].str[-1].str.isupper() == True:
tw4515['Unnamed: 0'].str[-1].str.lower()
tw4515 ['numed:0']的真实表如何有效地利用影响条件更改?
I have a column of strings that look similar to the following:
1 IX-1-a
2 IX-1-b
3 IX-1-C
4 IX-1-D
Some end in lowercase letters while others end in uppercase. I need to standardize all endings to lowercase without affecting the letters at the beginning of the string. Below is some code fragment that I am working with to make changes within the series but it doesn't quite work.
if i in tw4515['Unnamed: 0'].str[-1].str.isupper() == True:
tw4515['Unnamed: 0'].str[-1].str.lower()
How can the truth table from tw4515['Unnamed: 0'].str[-1].str.isupper()
be utilized efficiently to affect conditional changes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是从右侧分开一次,使第二部分小写,然后结合:
如果最后一部分始终是一个字母,@barmar的解决方案更好的
:
One option is to split once from the right side, make the second part lowercase, then combine:
If the last part is always a single letter, @Barmar's solution is even better:
Output: