pandas 代码正确,但某些语法没有升级,如何破解[重复]

xqkwcwgp  于 2023-04-28  发布在  其他
关注(0)|答案(1)|浏览(138)

此问题已在此处有答案

TypeError: unsupported operand type(s) for -: 'str' and 'float' comparing two dataframes(1个答案)
5天前关闭.

  1. df["eps"]= df["price"]/ df["eps"]

显示为:
TypeError:/不支持的操作数类型:'float'和'str'

  1. df["eps"]= df["price"]/ df["eps"]
dy1byipe

dy1byipe1#

您需要将它们转换为float,如下所示:

  1. df["eps"]= df["price"].astype(float)/ df["eps"].astype(float)

相关问题