繁体   English   中英

我在这方面做错了什么?

[英]What have I done wrong in this?

[在此处输入图像描述][1]```py df['Runs'] = df['Runs'].apply(lambda x: x[0] if x[-1]=="*" else x)


It shows 'int' object is not subscriptable error in Python.

I am trying to delete the last character of the column entries and parallelly convert it into integer or float.


  [1]: https://i.stack.imgur.com/HTCIa.png

我不知道实际代码,因为我没有要使用的条目,但是据我所知,错误正在发生,因为您在数组中使用了 integer 类型值

https://www.stechies.com/typeerror-int-object-is-not-subscriptable/#:~:text=This%20error%20occurs%20when%20you,that%20variable%20is%20an%20integer

根据您的操作,您可以将初始输入视为字符串,然后将其转换为 integer 用于 output

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM