首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >impyla as_pandas -空数据帧

impyla as_pandas -空数据帧
EN

Stack Overflow用户
提问于 2018-06-11 20:14:54
回答 2查看 2.3K关注 0票数 2

我有一个简单的impyla代码,我想从我的光标创建一个pandas dataFrame。我的代码正在运行,但我的dataframe始终是一个空dataframe。如果我直接在impala上运行查询,结果不是空的。我的代码是这样的:

代码语言:javascript
复制
from impala.dbapi import connect
from impala.util import as_pandas


conn = connect(host='impala_server', port=21051,
               user='user' , password='pass',
               use_ssl=True,
               auth_mechanism='PLAIN')
cursor = conn.cursor()
cursor.execute("SELECT * FROM TABLE")

results = cursor.fetchall()

df = as_pandas(cursor)

print(df.head())   

请帮帮我,我做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2018-11-19 20:21:35

只需删除:

代码语言:javascript
复制
results = cursor.fetchall()

从你的代码中。应该能行得通。

票数 1
EN

Stack Overflow用户

发布于 2020-07-21 16:40:06

代码语言:javascript
复制
'results = cursor.fetchall()  ' delete this line and it will be ok.

    from impala.dbapi import connect
    from impala.util import as_pandas
    
    conn = connect(host='****.com', port=****, database='****')
    cursor = conn.cursor()
    cursor.execute('select * from table limit 10')
    df = as_pandas(cursor)
    df.head()

我运行上面的代码,它运行得很好。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50797503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档