# Turn plain English into pandas code — with AST validation (free tool)

> Source: <https://dev.to/473185670/turn-plain-english-into-pandas-code-with-ast-validation-free-tool-46el>
> Published: 2026-08-17 00:41:33+00:00

If you use pandas daily, you have probably burned minutes hunting for the right syntax. `.agg()`

takes a dict or a list? `.rolling()`

then `.mean()`

— what is the window arg called?

I built a tool: describe what you want in English, get syntax-validated pandas code back.

Input:

```
Group sales by month, calculate total revenue and average order size
```

Output:

```
df['month'] = df['date'].dt.to_period('M')
result = df.groupby('month').agg(
    total_revenue=('revenue', 'sum'),
    avg_order_size=('order_size', 'mean')
).reset_index()
```

Note it auto-handled the datetime conversion — easy to miss on first write, then 10 minutes of debugging.

Three pieces, no black magic:

**Few-shot examples** (22 curated patterns): groupby+agg, merge/join, datetime, string ops, missing values, pivot, viz, binning, filtering, chaining. Not a generic LLM wrapper — tuned for pandas.

**Schema-aware**: upload a CSV or describe columns, and it knows `df['date']`

is datetime, `df['user_id']`

is string. No placeholder columns.

**AST validation**: runs `ast.parse()`

before returning. If the model hallucinates a nonexistent method, the validator flags it. You never get syntax-broken code — and it scans for dangerous ops (`eval`

, `exec`

, `subprocess`

, `os.remove`

).

7-day rolling average:

```
df['rolling_avg'] = df['close'].rolling(window=7).mean()
```

Quartile bins:

```
df['income_quartile'] = pd.qcut(df['income'], q=4, labels=['Q1','Q2','Q3','Q4'])
```

Correlation heatmap:

``` python
import seaborn as sns
sns.heatmap(df.corr(numeric_only=True), annot=True, cmap='coolwarm')
```

Honest value prop: saves the 20-30% of time spent on syntax lookup, so you spend it on the 70-80% that matters — understanding your data and reading results.

Free tier: 5 queries/day per IP, no signup.

Type a data operation in English, get validated pandas code. If you hit a pattern it handles well (or badly), tell me in the comments — the edge cases on messy real-world data are what I care about most.
