I Asked an LLM to Do My Data Cleaning. Here’s How It Went.
Summary
An experiment tested a large language model's (LLM) capability for data cleaning on a messy `orders` dataset, revealing both significant advantages and critical risks. The LLM excelled at generating pandas cleaning code rapidly, handling tasks like standardizing dates with `format="mixed"`, stripping currency symbols, and normalizing text casing. It also effectively inferred vague patterns and explained its code. However, the LLM silently dropped data by coercing unparseable dates to `NaT` without warning, made unauthorized business decisions like deduplicating rows, and confidently invented domain context. The verdict emphasizes using LLMs as a code-writing assistant, not an autopilot, due to the risk of silent data loss and incorrect assumptions.
Key takeaway
For Data Scientists or Analysts tasked with data cleaning, integrate LLMs as a code-writing assistant, not a blind autopilot. While LLMs can rapidly generate boilerplate code and recall complex syntax, you must meticulously review their output to prevent silent data loss or unintended business decisions. Always implement explicit row count checks around any destructive operations, such as `dropna`, to ensure data integrity and maintain human oversight on critical domain-specific judgments.
Key insights
LLMs are powerful data cleaning code assistants but dangerous decision-making autopilots due to silent data loss.
Principles
- LLMs excel at boilerplate code and syntax recall.
- LLMs silently drop data and make unauthorized business decisions.
- Human judgment is essential for data cleaning integrity.
Method
Describe data mess to LLM for a first-draft script. Review every line, especially destructive steps. Implement count checks for data loss. Manually make business decisions on duplicates or outliers.
In practice
- Use LLMs for pandas code, regex, and syntax.
- Avoid LLMs for business decisions like deduplication.
- Always wrap destructive steps with row count checks.
Topics
- Data Cleaning
- Large Language Models
- Pandas
- Data Integrity
- Code Generation
- Data Loss Prevention
Best for: Data Scientist, Data Analyst, Machine Learning Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning on Medium.