importpandas_gbqimportpydata_google_authSCOPES=['https://www.googleapis.com/auth/cloud-platform','https://www.googleapis.com/auth/drive',]credentials=pydata_google_auth.get_user_credentials(SCOPES,# Set auth_local_webserver to True to have a slightly more convienient# authorization flow. Note, this doesn't work if you're running from a# notebook on a remote sever, such as over SSH or with Google Colab.auth_local_webserver=True,df=pandas_gbq.read_gbq("SELECT my_col FROM `my_dataset.my_table`",project_id='YOUR-PROJECT-ID',credentials=credentials,)

Warning

Do not store credentials on disk when using shared computing resources
such as a GCE VM or Colab notebook. Use the
pydata_google_auth.cache.NOOP cache to avoid writing credentials
to disk.

importpydata_google_auth.cachecredentials=pydata_google_auth.get_user_credentials(SCOPES,# Use the NOOP cache to avoid writing credentials to disk.cache=pydata_google_auth.cache.NOOP,)

importpandas_gbqcredentials=...# From google-auth or pydata-google-auth library.# Update the in-memory credentials cache (added in pandas-gbq 0.7.0).pandas_gbq.context.credentials=credentialspandas_gbq.context.project="your-project-id"# The credentials and project_id arguments can be omitted.df=pandas_gbq.read_gbq("SELECT my_col FROM `my_dataset.my_table`")