Combining LangChain with Vertex AI Generative AI to ask plain English questions about a Pandas dataframes
When you want to examine tabular datasets in Python, the Pandas library is the natural tool to use. However, if you’re like me, and you’re not using Pandas on a daily basis, you need to do a little refresher every time you unpack a new CSV file or relational database table. What if you could just use plain English to examine tabular datasets in Pandas dataframes? As we’ll see in this article, it’s easy to use LangChain and Vertex AI Generative AI to do just that — ask questions in plain English about Pandas dataframes.
Get baseline answers for questions about a Pandas dataframe
To exercise the ability of Vertex AI Generative AI + LangChain to answer questions about a Pandas dataframe, I created a simple Python program to ingest a dataset into a Pandas dataframe and answer a set of questions about the dataset using both standard Pandas commands and LangChain + Vertex AI Generative AI. This program can be run directly in Cloud Shell in Google Cloud.
Here are the steps I followed:
- Select a dataset: I chose the Airbnb New York City listing dataset. I selected this dataset because it has a variety of column types and is of a manageable size…