data_std
Calculate standard deviation for each column in a dataset. Specify input file path and delta degrees of freedom (ddof) for precise statistical analysis.
Instructions
Standard deviation values for each column
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ddof | No | Delta Degrees of Freedom: the divisor used in the calculation is N - ddof | |
| input_data_file_path | Yes | Path to the input data file |
Implementation Reference
- The main handler function that processes input arguments, computes standard deviation on the dataframe columns, and returns the result as JSON text content.async def handle_data_std( arguments: dict[str, Any], ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: data_std_input = DataStdInputSchema.from_args(arguments) std_df = data_std_input.df.std(ddof=data_std_input.ddof) # Convert the DataFrame to a dictionary format std_dict = { "description": f"Standard deviation values for each column with ddof={data_std_input.ddof}", "std_values": {col: str(val) if val is not None else None for col, val in zip(std_df.columns, std_df.row(0))}, } return [ types.TextContent( type="text", text=json.dumps(std_dict), ) ]
- Pydantic input schema class for validating tool arguments, defining the JSON schema, and loading data from file into a dataframe with optional ddof parameter.class DataStdInputSchema(Data): model_config = ConfigDict( validate_assignment=True, frozen=True, extra="forbid", arbitrary_types_allowed=True, ) ddof: int = Field( default=1, description="Delta Degrees of Freedom: the divisor used in the calculation is N - ddof", ge=0 ) @staticmethod def input_schema() -> dict: return { "type": "object", "properties": { "input_data_file_path": { "type": "string", "description": "Path to the input data file", }, "ddof": { "type": "integer", "description": "Delta Degrees of Freedom: the divisor used in the calculation is N - ddof", "minimum": 0, "default": 1, }, }, "required": ["input_data_file_path"], } @staticmethod def from_schema(input_data_file_path: str, ddof: int = 1) -> "DataStdInputSchema": data = Data.from_file(input_data_file_path) return DataStdInputSchema( df=data.df, ddof=ddof, ) @staticmethod def from_args(arguments: dict[str, Any]) -> "DataStdInputSchema": input_data_file_path = arguments["input_data_file_path"] ddof = arguments.get("ddof", 1) return DataStdInputSchema.from_schema( input_data_file_path=input_data_file_path, ddof=ddof, )
- src/mcp_server_data_wrangler/tools/tools.py:137-141 (registration)Registers the 'data_std' tool in the MCP tools list with name, description, and input schema.types.Tool( name=MCPServerDataWrangler.data_std.value[0], description=MCPServerDataWrangler.data_std.value[1], inputSchema=DataStdInputSchema.input_schema(), ),
- src/mcp_server_data_wrangler/tools/tools.py:166-166 (registration)Maps the 'data_std' tool name to its handler function in the tool-to-handler dictionary.MCPServerDataWrangler.data_std.value[0]: handle_data_std,
- src/mcp_server_data_wrangler/tools/tools.py:54-54 (registration)Defines the tool name and description in the MCPServerDataWrangler enum.data_std = ("data_std", "Standard deviation values for each column")