0

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!

  • Could you provide the full traceback of the error ? `table_schema` must be a list of dicts (*see* [`to_gbq`](https://github.com/pandas-dev/pandas/blob/v2.0.2/pandas/core/frame.py#L1990-L2100)). – Timeless Jun 05 '23 at 22:41
  • 1
    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 – jagamts1 Jun 06 '23 at 06:51

1 Answers1

0

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