As of version 0.29.0, you can use the ~google.cloud.bigquery.table.RowIterator.to_dataframe
function to retrieve query results or table rows as a pandas.DataFrame
.
First, ensure that the pandas
library is installed by running:
pip install --upgrade pandas
Alternatively, you can install the BigQuery python client library with pandas
by running:
pip install --upgrade google-cloud-bigquery[pandas]
To retrieve query results as a pandas.DataFrame
:
../snippets.py
To retrieve table rows as a pandas.DataFrame
:
../snippets.py
GeoPandas adds geospatial analytics capabilities to Pandas. To retrieve query results containing GEOGRAPHY data as a geopandas.GeoDataFrame
:
../samples/geography/to_geodataframe.py
As of version 1.3.0, you can use the ~google.cloud.bigquery.client.Client.load_table_from_dataframe
function to load data from a pandas.DataFrame
to a ~google.cloud.bigquery.table.Table
. To use this function, in addition to pandas
, you will need to install the pyarrow
library. You can install the BigQuery python client library with pandas
and pyarrow
by running:
pip install --upgrade google-cloud-bigquery[pandas,pyarrow]
The following example demonstrates how to create a pandas.DataFrame
and load it into a new table:
../samples/load_table_dataframe.py