Skip to main content
Glama

replace_in_column

Replace text patterns in a CSV column using regex or literal matching. Clean data by substituting, removing, or standardizing values within specified columns.

Instructions

Replace patterns in a column with replacement text.

Returns: ColumnOperationResult with replacement details

Examples: # Replace with regex replace_in_column(ctx, "name", r"Mr.", "Mister")

# Remove non-digits from phone numbers
replace_in_column(ctx, "phone", r"\D", "", regex=True)

# Simple string replacement
replace_in_column(ctx, "status", "N/A", "Unknown", regex=False)

# Replace multiple spaces with single space
replace_in_column(ctx, "description", r"\s+", " ")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
columnYesColumn name to apply pattern replacement in
patternYesPattern to search for (regex or literal string)
replacementYesReplacement text to use for matches
regexYesWhether to treat pattern as regex (True) or literal string (False)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
successNoWhether operation completed successfully
operationYesType of operation performed
transformNoTransform description
part_indexNoPart index for split operations
nulls_filledNoNumber of null values filled
rows_removedNoNumber of rows removed (for remove_duplicates)
rows_affectedYesNumber of rows affected by operation
values_filledNoNumber of values filled (for fill_missing_values)
updated_sampleNoSample values after operation
original_sampleNoSample values before operation
columns_affectedYesNames of columns affected
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses the operation returns a 'ColumnOperationResult with replacement details' and shows through examples that it performs in-place column modifications. However, it doesn't mention potential side effects like data loss, performance implications for large datasets, or whether the operation is reversible - important behavioral traits for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with a clear purpose statement followed by practical examples. The examples are well-structured and demonstrate different use cases efficiently. However, the 'Returns:' section could be integrated more smoothly rather than as a separate statement.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations but with a complete input schema and output schema indicated, the description provides adequate context. The examples cover common use cases, and the mention of return type helps. For a pattern replacement operation, additional context about regex capabilities or limitations would enhance completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'patterns' and 'replacement text' but doesn't provide additional semantic context about parameter interactions or edge cases beyond what's in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Replace patterns in a column with replacement text') and distinguishes it from siblings like 'strip_column', 'transform_column_case', or 'update_column' by focusing on pattern-based replacement rather than other transformations. It explicitly mentions both regex and literal string replacement, which differentiates it from simple string operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context through examples showing when to use regex vs. literal string replacement, but doesn't explicitly state when NOT to use this tool or name specific alternatives among siblings. The examples imply usage for pattern-based column transformations, but no explicit guidance on alternatives like 'update_column' or 'strip_column' is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jonpspri/databeak'

If you have feedback or need assistance with the MCP directory API, please join our Discord server