简体   繁体   English

在 dataframe 中划分两列值时出错

[英]Error while dividing two columns value in a dataframe

I am receiving an error while dividing two columns value in a dataframe.在 dataframe 中划分两列值时收到错误消息。 This is the code:这是代码:

df['lose%'] =  df['LostGames']/ df['PlayedGames']

This is my error:这是我的错误:

TypeError: unsupported operand type(s) for /: 'str' and 'str' TypeError:不支持的操作数类型/:'str'和'str'

Can anyone help me with this??谁能帮我这个??

df1.WonGames = pd.to_numeric(df1.WonGames) df1.WonGames = pd.to_numeric(df1.WonGames)

df1.LostGames = pd.to_numeric(df1.LostGames) df1.LostGames = pd.to_numeric(df1.LostGames)

df1.PlayedGames = pd.to_numeric(df1.PlayedGames) df1.PlayedGames = pd.to_numeric(df1.PlayedGames)


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

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