<jupyter_start><jupyter_text>Accessing BigQuery from ColabThis notebook shows the simple steps needed to enable BigQuery access from a Colab notebook.First, we need to authenticate this notebook so we get access to our Google Cloud account. Follow these steps:1. Execute the cell below2. Click on the provided URL3. Select the account you wish to give access to4. Allow access5. Copy the passcode and past it in the box provided under the cell below<jupyter_code>from google.colab import auth
auth.authenticate_user()<jupyter_output><empty_output><jupyter_text>Using `bigquery` magic functionYou will need to specify which project this query will be billed to by providing `--project=`. You will need to replace your project ID with ``. Using this magic function, your cell becomes entirely a *BigQuery* cell and no longer operates as a *python* cell.Below is a simple example:<jupyter_code>%%bigquery --project=ba-770
SELECT corpus, SUM(word_count) total_word_count
FROM `bigquery-public-data.samples.shakespeare` 
GROUP BY corpus
ORDER BY total_word_count DESC
LIMIT 5<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.05818181818181818, 'fraction_numerical': 0.008181818181818182, 'mean_word_length': 5.754601226993865, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '481083', 'license': 'MIT', 'n_tokens_mistral': 309, 'n_tokens_neox': 299, 'n_words': 140, 'path': '03-Data-Warehousing/03-02-Colab-BigQuery.ipynb', 'repo_name': 'JQmiracle/Business-Analytics-Toolbox', 'size': '1100'}