I am trying to save the results of a BigQuery query to a Panda DataFrame using bigquery.Client.query.to_dataframe()
This query can return millions of rows.
Given that Panda to BQ (Dataframe.to_gbq()
) has a chunk parameter, is there something similar for BQ to Pandas to incrementally add to the dataframe without having to run the query multiple times with a limit and offset?
You can use to_dataframe_iterable
instead to do this.
job = client.query(query)
result = job.result(page_size=20)
for df in result.to_dataframe_iterable():
# df will have at most 20 rows
print(df)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With