【问题标题】:Pandas read_gbq not working correctly?熊猫 read_gbq 无法正常工作?
【发布时间】:2018-05-13 08:48:49
【问题描述】:

我正在尝试在 google BigQuery 的数据集中合并两个表

使用以下代码:

def mergeTables(workingTable, table, DATASET_ID):
    query ="""
        SELECT
            full_name,
            age
        FROM {DATASET_ID}.{workingTable}
        UNION DISTINCT
        SELECT
            full_name,
            age
        FROM {DATASET_ID}.{table}
        LIMIT 100;
        """
    df = pd.read_gbq(query, "joe-python-analytics", 'standard')
    print(df)

工作表和表是我希望与联合运算符合并的两个表。但是,当我运行该方法时,我得到了错误:

googleapiclient.errors.HttpError: <HttpError 400 when requesting https://www.googleapis.com/bigquery/v2/projects/j/queries/job_aalt=json returned "Encountered "" at line 6, column 15.
[Try using standard SQL (https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)]">

我已经启用了标准 sql,这似乎没有帮助?

【问题讨论】:

    标签: python mysql google-bigquery


    【解决方案1】:

    尝试使输入对 Python 显式,如下所示:

    df = pd.read_gbq(query,
                     project_id="joe-python-analytics",
                     dialect='standard')
    

    正如您从 method contract 中看到的那样,它需要 sereval 关键字参数,因此您使用它的方式没有正确设置标准方言。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      • 2020-11-09
      • 2021-08-27
      相关资源
      最近更新 更多