{"slug": "turn-plain-english-into-pandas-code-with-ast-validation-free-tool", "title": "Turn plain English into pandas code — with AST validation (free tool)", "summary": "A developer has built a free tool that converts plain English descriptions into syntax-validated pandas code, using AST validation to catch errors and block dangerous operations. The tool includes 22 curated few-shot examples, schema awareness for CSV uploads, and a free tier of 5 queries per day per IP.", "body_md": "If you use pandas daily, you have probably burned minutes hunting for the right syntax. `.agg()`\n\ntakes a dict or a list? `.rolling()`\n\nthen `.mean()`\n\n— what is the window arg called?\n\nI built a tool: describe what you want in English, get syntax-validated pandas code back.\n\nInput:\n\n```\nGroup sales by month, calculate total revenue and average order size\n```\n\nOutput:\n\n```\ndf['month'] = df['date'].dt.to_period('M')\nresult = df.groupby('month').agg(\n    total_revenue=('revenue', 'sum'),\n    avg_order_size=('order_size', 'mean')\n).reset_index()\n```\n\nNote it auto-handled the datetime conversion — easy to miss on first write, then 10 minutes of debugging.\n\nThree pieces, no black magic:\n\n**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.\n\n**Schema-aware**: upload a CSV or describe columns, and it knows `df['date']`\n\nis datetime, `df['user_id']`\n\nis string. No placeholder columns.\n\n**AST validation**: runs `ast.parse()`\n\nbefore 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`\n\n, `exec`\n\n, `subprocess`\n\n, `os.remove`\n\n).\n\n7-day rolling average:\n\n```\ndf['rolling_avg'] = df['close'].rolling(window=7).mean()\n```\n\nQuartile bins:\n\n```\ndf['income_quartile'] = pd.qcut(df['income'], q=4, labels=['Q1','Q2','Q3','Q4'])\n```\n\nCorrelation heatmap:\n\n``` python\nimport seaborn as sns\nsns.heatmap(df.corr(numeric_only=True), annot=True, cmap='coolwarm')\n```\n\nHonest 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.\n\nFree tier: 5 queries/day per IP, no signup.\n\nType 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.", "url": "https://wpnews.pro/news/turn-plain-english-into-pandas-code-with-ast-validation-free-tool", "canonical_source": "https://dev.to/473185670/turn-plain-english-into-pandas-code-with-ast-validation-free-tool-46el", "published_at": "2026-08-17 00:41:33+00:00", "updated_at": "2026-08-17 01:11:44.960261+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence", "natural-language-processing"], "entities": ["pandas", "AST"], "alternates": {"html": "https://wpnews.pro/news/turn-plain-english-into-pandas-code-with-ast-validation-free-tool", "markdown": "https://wpnews.pro/news/turn-plain-english-into-pandas-code-with-ast-validation-free-tool.md", "text": "https://wpnews.pro/news/turn-plain-english-into-pandas-code-with-ast-validation-free-tool.txt", "jsonld": "https://wpnews.pro/news/turn-plain-english-into-pandas-code-with-ast-validation-free-tool.jsonld"}}