Python 从大查询查询时出现Pyarrow错误
运行下面的代码时,我收到一个pyarrow错误。我已经安装了pyarrow,但仍然收到相同的错误。我能够访问该表并查看模式等。但是当复制与Google Bigquery文档相同的代码时,到_dataframe()不起作用Python 从大查询查询时出现Pyarrow错误,python,pandas,google-bigquery,pyarrow,Python,Pandas,Google Bigquery,Pyarrow,运行下面的代码时,我收到一个pyarrow错误。我已经安装了pyarrow,但仍然收到相同的错误。我能够访问该表并查看模式等。但是当复制与Google Bigquery文档相同的代码时,到_dataframe()不起作用 from google.cloud import bigquery from google.oauth2 import service_account key_path = key_path #personal json file credentials = service_
from google.cloud import bigquery
from google.oauth2 import service_account
key_path = key_path #personal json file
credentials = service_account.Credentials.from_service_account_file(
key_path, scopes=["https://www.googleapis.com/auth/cloud-platform"],
)
client = bigquery.Client(credentials=credentials, project=credentials.project_id,)
query = """
select *
from `table`
limit 10;
"""
df = client.query(query).to_dataframe() # I have also tried with df = client.query(query).result().to_dataframe()
我在运行时收到以下错误:
ValueError: The pyarrow library is not installed, please install pyarrow to use the to_arrow() function.
试试这个:将熊猫作为pd导入
query\u string=“”从表限制10中选择*”
df=pd.read\u gbq(query\u string,project\u id,dialogue='standard')
如果在python shell中运行import pyarrow
会发生什么?导入没有问题。查询的错误消息与以前相同。我在我的环境中尝试了您的代码。你能试试“pip安装——升级谷歌云大查询[熊猫]”吗?此安装添加了一些可能丢失的库。并检查版本是否兼容。在我的环境中,库的版本如下:GoogleCloudBigQuery,版本:2.16.0和pyarrow,版本:3.0.0。我之所以提出这个建议,是因为我无法重新创建这个问题,因为您的代码对我来说运行得非常好。这是一个不同的库,我无法使用,因为它需要授权,并且不是google bigquery库。