我正在测试使用PostgreSQL从Amazon Redshift数据库到本地数据库的简单连接。我编写了一个查询以从数据库中获取表,然后将其转换为Pandas数据框。现在,每当我想在数据框对象上应用某些功能时,都会出现以下错误。我已经尝试过几次修改它,并查看了很多解决方案,但似乎无法解决它。
cur.execute("QUERY for PostgreSQL")
rows = cur.fetchall()
print("Received as rows")
col_names = []
for i in cur.description:
col_names.append(i[0])
df = pd.DataFrame.from_records(rows, columns = col_names)
df.values()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-8e9714b76ea1> in <module>()
----> df.values()
TypeError: 'numpy.ndarray' object is not callable
Run Code Online (Sandbox Code Playgroud)