Skip to main content
Glama

impute_missing

Fill missing values in numeric columns using rule-based strategies (mean, median, forward/backward fill, or constant). The imputed data is saved to a new CSV and its absolute path is returned.

Instructions

impute_missing —— 数据探查组 · 缺失值插补(工具 28,v1.2.0 新增)。

与 missing_report 互补的确定性整治工具:只做规则插补(mean/median/ffill/bfill/constant), 不做任何"智能推断";绝不修改输入文件,插补结果写入 reports/imputed/ 新 CSV 并以 output 返回绝对路径(SPEC 第 11 节文件输出协议)。

docstring = agent 使用说明书,与 statlab_mcp/docs/design/01_data_exploration_batch1.md 同步维护。

参数: file_path (str): 本地数据文件(csv/tsv/xlsx/json),仅接受本地路径 columns (list[str]|None): 待插补的数值列清单;缺省 = 全部含缺失的数值列 (显式传入时逐列校验:不存在 → E1008;非数值列含 object 伪数值列 → E1009) strategy (str, "mean"): mean / median / ffill / bfill / constant; mean/median 仅基于有限观测计算(±Inf 不算缺失也不计入均值——排除数进 result) value (float|None): 仅 strategy="constant" 时必填的填充值(有限数, 拒绝 NaN/Inf/bool);其它策略携带本参数 → E1001

边界(钉死): - 无任何可插补对象 → E1012 中文报错,三种情形 message 独立: 全表无缺失 / 指定列均无缺失 / 缺失仅位于非数值列; - 列全缺失且策略为 mean/median/ffill/bfill 时无来源可用 → 该列跳过原样保留, 在 result.skipped_columns 与 summary 如实注明(不报错);constant 对全缺失列生效; - 输出文件 = reports/imputed/YYYYmmdd/impute_missing_<干名>_<策略>_YYYYmmdd_HHMMSS_fff.csv (utf-8-sig;Excel 公式注入转义与控制字符清洗见 SPEC 第 11 节第 5 条)。

返回: 成功 result 含 {columns_processed:[{column,strategy,filled,value_or_direction, excluded_nonfinite,residual_missing}], skipped_columns:[...], output_dir} + 顶层 output = 插补文件绝对路径。 局限声明(固定附于 summary 末尾):插补值为确定性规则估计,会低估方差、可能引入偏差, 后续分析请注明使用了插补数据。

示例: impute_missing("samples/dirty.csv") # 默认全部数值缺失列、均值 impute_missing("samples/dirty.csv", columns=["score"], strategy="median") impute_missing("samples/dirty.csv", columns=["note"], strategy="constant", value=0) inline 数据: 本工具支持可选 inline_data 参数(v1.2.0 起):与 file_path 二选一, 支持 records 数组或 {"header": [...], "rows": [[...], ...]} 对象两种形态; 规模上限/类型域/data_source 来源标注见 statlab_mcp/docs/SPEC.md 第 12 节。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueNo
columnsNo
strategyNomean
file_pathNo
inline_dataNo

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.2.0

TDQS

A4.9/5.0
Behavior5/5

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

没有 annotations,描述承担了全部行为披露义务:明确“绝不修改输入文件”、输出写入 reports/imputed/ 并返回绝对路径、全缺失列会跳过并如实记录、文件写入有 utf-8-sig 和公式注入转义、固定附加局限声明。这些信息远超基本说明,行为非常透明。

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?

描述结构清晰,按功能、参数、边界、返回、示例分段,信息密度高且可读性强。扣一分是因为夹杂了“工具 28”“docstring 同步维护”等元信息,对工具调用本身不是必须,略有冗余。

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

Completeness5/5

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

在无输出 schema、无 annotations、5 个参数且行为复杂的条件下,描述覆盖了参数语义、返回结构、错误码、边界行为、输出路径、局限声明和示例,足以让 agent 无需查阅额外资料即能正确调用并预期结果。

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

Parameters5/5

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

schema 描述覆盖率为 0%,描述完全补偿了参数语义:逐一解释了 file_path、columns、strategy、value、inline_data 的含义、默认值、约束和错误码,还说明了 mean/median 对 ±Inf 的处理及 constant 与 value 的依赖关系,比 schema 本身给出更多可操作信息。

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?

描述首句明确点名“缺失值插补”和“数据探查组·确定性整治工具”,指出处理对象是缺失值、方法是规则插补、输出是新 CSV,并与 missing_report 明确区分。工具用途一眼可辨,不会与同组分析/绘图类工具混淆。

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

Usage Guidelines5/5

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

描述明确指出 missing_report 是互补工具,且限定“只做规则插补,不做智能推断”,等于给出了使用边界;还在参数部分说明了 file_path 与 inline_data 二选一、value 仅在 constant 策略下使用,提供了清晰的选型和使用条件。

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

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/good-boy4069/statlab-mcp'

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