Python

How to: Query data in BigQuery from Vertex AI

March 14, 2023
Cloud
Python, Vertex AI

I often grab data for a Vertex AI instance from BigQuery and shape it into a dataframe to do work. Minimum viable snippet to get that to work: import pandas as pd from google.cloud import bigquery client = bigquery.Client() query_string = "<some SQL query>" df = client.query(query_string).to_dataframe()

How to: Read a Google Cloud Storage .csv to a Vertex Pandas Dataframe

March 13, 2023
Cloud
Pandas, Python, SQL

I often find it useful to stash .csv files in a Google Cloud Storage (GCS) bucket to be accessed from a Vertex JupyterLabs notebook. Once the file(s) are accessible from Vertex, I can do all sorts of things with it. One of the most common operations I perform in this scenario is to use the data in the .csv to create a Pandas dataframe that can in turn be used to enrich other data that I have stored in a BigQuery implementation. ...

How to: Hide all the warnings in Jupyter Notebooks

February 25, 2023
Data Science
Python, Jupyter

If you’re a data scientist, there’s a good chance that you spend a healthy chunk of time working in Jupyter Notebooks. Every now and then, you might do something that triggers a warning (such as ::ahem:: using a deprecated method from the Pandas package). That warning can get end up consuming a whole lot of screen real estate, especially if it’s part of a looping function. One way to deal with those warnings is to simply make them disappear by adding the following chunk in a cell near the top of the notebook: ...