下面是一个数据帧。在
a = {'Id': ['ants', 'bees', 'cows', 'snakes', 'horses'], '2nd Attempts': [10, 12, 15, 14, 0],
'3rd Attempts': [10, 10, 9, 11, 10]}
a = pd.DataFrame(a)
print (a)
我希望能够添加文本('-s')到任何等于4个字符。我尝试了以下方法,但没有成功。当它产生错误时,ValueError:序列的真值是不明确的。使用a.empty、a.bool()、a.item()、a.any()或a.all()。在
^{pr2}$
我认为您需要
loc
,如果需要替换最后一个s
,请添加$
:带^{} 的解决方案:
^{pr2}$相关问题 更多 >
编程相关推荐