Sketch: Ask a Pandas DataFrame Questions in Plain English
Sketch adds an AI helper to pandas: df.sketch.ask answers a question about a DataFrame in plain English, and df.sketch.howto writes the pandas code for what you want. It sends a summary of your data to a language model rather than the full table, which still matters for privacy.
Update (November 2026): Sketch has had no new release since February 2024, so test it on sample data first, or use the maintained PandasAI instead.
Install Sketch
Sketch is a pip package. Install it in your terminal, then import it next to pandas. The import adds a .sketch accessor to every DataFrame.
pip install sketch
import pandas as pd
import sketch

Ask questions about the data
df.sketch.ask answers questions about a DataFrame in plain English. I loaded a supermarket sales dataset and asked what it is about. Sketch answered that it describes customer purchases and listed the columns.
df = pd.read_csv("https://raw.githubusercontent.com/Sven-Bo/datasets/master/supermarket_sales.csv")
df.head()
df.sketch.ask("What is this dataset about?")
Friendly names and a one-sentence description per column are useful when the headers are abbreviations such as cogs. You can even ask for the answer as an HTML list.
df.sketch.ask("Can you give me friendly names and single sentence descriptions of each column? (format output as HTML List)")
Asked for analysis ideas, Sketch suggested comparing sales across branches and product lines, looking at sales over time, and checking relationships such as customer type and gender:
df.sketch.ask("What interesting analysis could we perform?")
We could perform a variety of interesting analyses on this data. For example, we could look at the relationship between customer type and gender, or the relationship between city and payment type. We could also look at the distribution of ratings across different product lines, or compare the total sales across different branches. Additionally, we could analyze the correlation between unit price and quantity, or between cogs and gross income. Finally, we could look at the distribution of total sales over time to identify any trends.
Generate code with howto
df.sketch.howto returns pandas code instead of an answer. You copy it into a new cell and run it. For the relationship between rating and total sale, it used the Total column even though I wrote “total sale”, and produced a labelled scatter plot. The plot showed no clear correlation.
df.sketch.howto("Analyze the relationship between rating and total sale")
# Calculate the correlation between rating and total sale
corr = df['Rating'].corr(df['Total'])
# Plot a scatter plot to visualize the relationship between rating and total sale
import matplotlib.pyplot as plt
plt.scatter(df['Rating'], df['Total'])
plt.xlabel('Rating')
plt.ylabel('Total Sale')
plt.title('Relationship between Rating and Total Sale')
plt.show()
The dataset has no profit column, so for the most profitable product lines Sketch first creates one from Total minus cogs, then groups and sorts. Writing that by hand is short too: nlargest and groupby do most of the work.
df.sketch.howto("Calculate the product lines with the highest profits")
# Calculate the product lines with the highest profits
# Create a new column for profit
df['profit'] = df['Total'] - df['cogs']
# Group by product line and calculate the sum of profits
product_profits = df.groupby('Product line')['profit'].sum()
# Sort the values in descending order and get the top 5 product lines with highest profits
top_5_product_profits = product_profits.sort_values(ascending=False).head(5)
# Print the top 5 product lines with highest profits
print(top_5_product_profits)
Product line
Food and beverages 2673.5640
Sports and travel 2624.8965
Electronic accessories 2587.5015
Fashion accessories 2585.9950
Home and lifestyle 2564.8530
Name: profit, dtype: float64
Plots work the same way. For total sales by gender it wrote a matplotlib bar chart. You can also name the library, as in the hourly chart below with Plotly.
df.sketch.howto("Create a plot to show sales by gender")
# import libraries
import matplotlib.pyplot as plt
# create a plot to show sales by gender
df.groupby('Gender')['Total'].sum().plot(kind='bar')
plt.title('Sales by Gender')
plt.xlabel('Gender')
plt.ylabel('Total Sales')
plt.show()
For the hourly chart, the generated code takes the first two characters of the Time column as the hour and sums the sales per hour:
df.sketch.howto("Using Plotly, plot the total sales by each hour of the day")
import plotly.express as px
# Create a dataframe with the total sales by each hour of the day
df_hourly = df.groupby(df['Time'].str[:2]).agg({'Total': 'sum'}).reset_index()
# Plot the total sales by each hour of the day using Plotly
fig = px.bar(df_hourly, x='Time', y='Total', title='Total Sales by Hour of the Day')
fig.show()

Privacy
Sketch sends a summary of your data to a large language model, according to its GitHub repository. The summary is not the full table, but it is derived from your data, so be careful with sensitive or proprietary information.
When I looked at PandasAI, the version I used randomized the data before processing. Sketch does not do that. If you would rather chat with your data than call a library, see how I use ChatGPT as a data analyst.
