使用pandas-gbq.to_gbq添加表格描述。

huangapple go评论141阅读模式
英文:

Adding table description using pandas-gbq.to_gbq

问题

I am using the library pandas-gbq.to_gbq to create my tables on Google Big Query. Everything is working fine, except for the fact that I wasn't able to add the table description using this function (not column description). I've tried:

schema = {
    "description": "Description here",
    "fields": [
        {
            "name": "nome",
            "type": "STRING",
            "description": "Blablabla"
        },
        {
            "name": "numero",
            "type": "INT64",
            "description": "Blablabla"
        }
    ]
}

df = pd.DataFrame({"nome": ["Monique", "Rodrigo"],
                   "numero": [1, 2]})

df.to_gbq(table, project_id=project_id, if_exists="replace", table_schema=schema)

But I got the error:

TypeError: string indices must be integers

Is it possible to add the description using this function? Thanks!

英文:

I am using the library pandas-gbq.to_gbq to create my tables on Google Big Query. Everything is working fine, except for the fact that I wasn't able to add the table description using this function (not column description). I've tried:

schema = {
    "description": "Description here",
    "fields": [
            {
                "name": "nome",
                "type": "STRING",
                "description": "Blablabla"
            },
            {
                "name": "numero",
                "type": "INT64",
                "description": "Blablabla"
            }
        
        ]
}

df = pd.DataFrame({"nome": ["Monique", "Rodrigo"],
                   "numero": [1, 2]})

df.to_gbq(table, project_id=project_id,if_exists="replace", table_schema = schema)

But I got the error:

> TypeError: string indices must be integers

Is it possible to add the description using this function? Thanks!

答案1

得分: 0

就像@jagamts1在评论中写的那样:

> 我们无法使用gbq更新表的描述。一旦表被创建,您可以使用更新选项来更新表的描述。
> https://cloud.google.com/bigquery/docs/samples/bigquery-update-table-description?hl=pt-br

英文:

Like @jagamts1 have written in the comments:

> We can't update the table descriptions using gbq. Once the table is
> created, you can update the table description by update option.
> https://cloud.google.com/bigquery/docs/samples/bigquery-update-table-description?hl=pt-br

huangapple
  • 本文由 发表于 2023年6月6日 05:18:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410074.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定