简体   繁体   中英

ValueError: install DBtypes to use this function

I'm using BigQuery for the first time.

client.list_rows(table, max_results = 5).to_dataframe();

Whenever I use to_dataframe() it raises this error:

ValueError: Please install the 'db-dtypes' package to use this function.

I found this similar problem (almost exactly the same), but I can't understand how to implement their proposed solution.

The most robust way to resolve this is to specify that you also want to install the pandas extra dependencies when installing the google-cloud-bigquery package. You'd do this by

  • running pip install 'google-cloud-bigquery[pandas]' , or
  • putting eg google-cloud-bigquery[pandas]==2.34.3 in your requirements.txt .

I was able to replicate your use case as shown below. 在此处输入图像描述

Easiest solution is to pip install db-dtypes as mentioned by @MattDMo.

Or you can specify previous version of google-cloud-bigquery by creating a requirements.txt with below contents:

google-cloud-bigquery==2.34.3

And then pip install by using command as shown below:

pip install -r /path/to/requirements.txt

Output of my sample replication: 在此处输入图像描述

Make sure pandas is installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM