python - 语法错误循环(TypeError:'DataFrame' 对象不可调用)
问题描述
如何解决问题?我有一个关于 python 的作业,我想在 csv 中循环数据,这是我的代码
import pandas as p
import numpy as np
df = p.read_csv("mlp.csv")
dataInp = df.drop(["output"],axis=1)
dataOup = df["output"]
v1 = 1.718946
v2 = -1.263178
v3 = -1.083092
w1 = -0.541180
w2 = 0.54360
i=0
j=0
for i in dataInp:
for j in dataInp:
z_in = (dataInp(i,j)*v1)
print(z_in)
和错误输出:
Traceback (most recent call last):
File "user\a.py", line 22, in <module>
z_in = (dataInp(i,j)*v1)
TypeError: 'DataFrame' object is not callable
解决方案
当您应该在行上使用方括号时,您似乎正在使用括号z_in = (dataInp(i,j)*v1)
更正后的代码是z_in = (dataInp[i,j]*v1)
因为您使用的是括号,python 将它解释为好像您试图dataInp
作为函数调用一样。
推荐阅读
- html - 引导模板适用于 index.html 但不适用于任何反应组件?
- python - 如何在循环中读取 csv 文件
- reactjs - 如何使我的 setValue +1 代码变为 12345 而不是 11111
- php - PHP调用python脚本和按钮在php中单击后消失
- azure - Linux VMSS 操作系统磁盘自动增长选项
- reactjs - 第 31:7 行:React Hook useEffect 缺少依赖项:'url'。包括它还是删除依赖数组?
- c++ - 为什么我的伺服电机在尝试前进时不会停止旋转?
- java - 在实体到多 JPA 之间创建关联
- javascript - React - 如何在我的表单内返回 Axios 捕获错误?
- python-3.x - 在类中查找选项卡错误的原因