0

I have the results from a query obtained through Python:

<google.cloud.bigquery.table.RowIterator object at 0x00000289E881C670>

I'd like to convert them to a pandas Dataframe.

I'm trying things like df = pd.read_sql_query(query, connection), but I don't have the connection.

My code to get the query results is

import pandas as pd
from google.cloud import bigquery
from google.oauth2 import service_account

# Load BigQuery credentials
credentials_json_file = r"credentials.json"
credentials = service_account.Credentials.from_service_account_file(credentials_json_file)
project_id = "idi-rewan"
client = bigquery.Client(credentials=credentials, project=project_id)

# Define query
query_string = """
   SELECT * FROM `database.table`
   """
query_job = client.query(query_string)

results = query_job.result()

1 Answer 1

2

You can use the pandas-gbq package and use the read_gbq function as suggested in this post.

The read_gbq function takes the SQL string as argument and the different credentials for the authentication.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.