Xavier: Toward Better Coding Assistance in Authoring Tabular Data Wrangling Scripts

Yunfan Zhou, Xiwen Cai, Qiming Shi, Yanwei Huang, Haotian Li, Huamin Qu, Di Weng, Yingcai Wu

Abstract

Data wrangling remains a significant bottleneck in data science, characterized by a high context-switching overhead between code authoring and data inspection. Current AI-powered coding assistants often suffer from "data blindness," lacking awareness of the underlying data schema and values, which leads to hallucinations and execution errors. This paper presents Xavier, a computational notebook extension that integrates real-time data context into the code completion process. By injecting live data schemas and sample rows into Large Language Model (LLM) prompts, Xavier provides data-aware completions and real-time transformation previews. Evaluation with 16 data analysts demonstrates that Xavier significantly reduces manual data inspection, minimizes coding errors, and lowers the mental workload of data wrangling tasks.

Introduction

Data wrangling—the process of cleaning, merging, and transforming data—is a core component of the data science lifecycle. Despite the rise of AI assistants like GitHub Copilot, writing Pandas scripts remains a "guessing game" for many practitioners. The primary challenge is that these models typically only see the code context, not the actual data residing in the user's memory. This lack of data awareness forces users into a repetitive "ping-pong" workflow: writing code, encountering a KeyError or unexpected output, manually running df.head() to verify column names or types, and then returning to the code to fix the error.

Xavier is designed to bridge this gap by making data context a first-class citizen in the code completion process. By providing real-time previews and data-aware suggestions, Xavier aims to reduce the cognitive load and context-switching overhead inherent in tabular data manipulation.

The Xavier System

Xavier operates as an extension for computational notebooks, bridging the gap between the code editor and the data kernel through three primary components:

1. Code Context Manager

This component utilizes Abstract Syntax Tree (AST) parsing to detect the user's intent in real-time. By analyzing the current line of code and the surrounding block, Xavier can identify specific operations, such as a join (pd.merge) or a string manipulation, to tailor its suggestions accordingly.

2. Data Context Manager

The Data Context Manager profiles active DataFrames within the notebook kernel. It extracts critical metadata, including schemas, data types, and cardinality, along with representative sample rows. This ensures the assistant is aware of the actual structure of the data the user is manipulating.

3. Completion Generator

Unlike standard tools that rely solely on code, Xavier feeds both the code context and the relevant data snippets into a Large Language Model (specifically Llama3-70B). This allows the model to suggest column names that actually exist and transformations that are compatible with the data's format.

User Interface and Interaction

Xavier features an "always-on" side panel that provides immediate feedback. As a user types, the sidebar automatically unfolds the relevant DataFrame and highlights the columns mentioned in the code. Most notably, it provides a real-time preview of transformations—such as string replacements or filters—allowing users to see the result of their code before they even execute the cell.

Evaluation

The authors evaluated Xavier using two primary tabular datasets modified from Kaggle to ensure the LLM had not memorized them: a Covid-19 Dataset (multi-table, focused on joins and filtering) and a Movies Dataset (Netflix titles, focused on string manipulation).

A user study was conducted with 16 data analysts, comparing Xavier against a baseline consisting of Llama3 without data context and a standard data profiler. The study focused on both quantitative performance and qualitative user experience.

Key Insights

  • Relevance Filtering: To manage the limited context window of LLMs, Xavier dynamically selects only the most relevant data segments (specific columns or sample rows) based on the user's cursor position, rather than attempting to process the entire dataset.
  • The Confidence Sidebar: The side panel served as a vital "sanity check." If the sidebar failed to highlight a column as the user typed, they immediately recognized a typo, allowing for self-correction before execution.
  • Granularity of Assistance: Users expressed a preference for shorter, specific completions (e.g., a single column name or parameter) over long blocks of generated code. These shorter suggestions were easier to verify against the live data view and felt more like collaborative assistance.

Results

The study yielded several significant findings:

  • Reduced Context Switching: Users performed significantly fewer manual data inspections (p < 0.001) compared to the baseline.
  • Improved Accuracy: There was a marked drop in coding errors, particularly those involving non-existent columns or incorrect data types.
  • Lower Cognitive Load: NASA-TLX scores indicated a decrease in mental demand and frustration.
  • User Preference: 14 out of 16 participants rated Xavier’s completions as "better" or "smarter" than standard, data-blind tools.

Limitations and Future Work

While Xavier represents a significant step forward, several challenges remain. The inclusion of data context increases prompt size, which can lead to higher latency in LLM response times. Additionally, for massive datasets, the tool relies on sampling; determining the "optimal" sample that accurately represents complex data for an LLM remains an open research question. Future iterations may expand support beyond Pandas to other libraries like SQL or R's dplyr through the use of intermediate domain-specific languages (DSLs).

Summary updated

BibTeX
@misc{zhou2025xavier,
  author = {Yunfan Zhou and Xiwen Cai and Qiming Shi and Yanwei Huang and Haotian Li and Huamin Qu and Di Weng and Yingcai Wu},
  title = {{Xavier: Toward Better Coding Assistance in Authoring Tabular Data Wrangling Scripts}},
  year = {2025},
  eprint = {2503.02639},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.02639},
}
Figure