I Asked an LLM to Do My Data Cleaning. Here’s How It Went.

· Source: Machine Learning on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Data Science & Analytics · Depth: Intermediate, short

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

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

Topics

Best for: Data Scientist, Data Analyst, Machine Learning Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning on Medium.