pandasgoogle-cloud-platformgoogle-bigquerypandas.dataframe.to-gbq

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!


Solution

  • 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