ohe = OneHotEncoder(sparse=False)
ohe.fit_transform(file(['Areas of interest']))
我遇到了错误:
TypeError: 'DataFrame' object is not callable
答案 0 :(得分:1)
如您收到的错误消息所暗示,file
可能是熊猫DataFrame。
在fit_transform()
内部,您已经写过:
file(['Areas of interest'])
正确的方法是:
file['Areas of interest']
在第一种情况下,多余的括号会导致您收到错误,因为file
不是函数而是数据帧。
您不调用数据框(使用括号表示您正在尝试将参数传递给函数),而是通过对它们进行索引(使用方括号[]
(以列名作为参数)来对其进行访问)
可以用许多其他方式来建立索引。有关更多详细信息,请参见pandas user manual。