我尝试在jupyter笔记本上的python 2.7中实现bigquery。我认为我的代码是正确的,但出现错误“ AttributeError:'客户端'对象没有属性'查询'”
# Create SQL query using natality data after the year 2000
query = """
SELECT
weight_pounds,
is_male,
mother_age,
plurality,
gestation_weeks,
ABS(FARM_FINGERPRINT(CONCAT(CAST(YEAR AS STRING), CAST(month AS STRING)))) AS hashmonth
FROM
publicdata.samples.natality
WHERE year > 2000
"""
# Call BigQuery and examine in dataframe
from google.cloud import bigquery
client = bigquery.Client()
df = client.query(query + " LIMIT 100").to_dataframe()
df.head()
我收到的错误消息是:
AttributeErrorTraceback (most recent call last)
<ipython-input-12-caf57b3f137d> in <module>()
2 from google.cloud import bigquery
3 client = bigquery.Client()
----> 4 df = client.query(query + " LIMIT 100").to_dataframe()
5 df.head()
AttributeError: 'Client' object has no attribute 'query'
答案 0 :(得分:0)
问题已解决!只需通过以下方式更新bigquery
pip install --upgrade google-cloud-bigquery