fill_missing_values
Handle missing data in CSV files using strategies like drop, fill with specific values, forward/backward fill, or statistical imputation methods for complete datasets.
Instructions
Fill or remove missing values with comprehensive strategy support.
Provides multiple strategies for handling missing data, including statistical imputation methods. Handles different data types appropriately and validates strategy compatibility with column types.
Examples: # Drop rows with any missing values fill_missing_values(ctx, strategy="drop")
# Fill missing values with 0
fill_missing_values(ctx, strategy="fill", value=0)
# Forward fill specific columns
fill_missing_values(ctx, strategy="forward", columns=["price", "quantity"])
# Fill with column mean for numeric columns
fill_missing_values(ctx, strategy="mean", columns=["age", "salary"])
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| strategy | No | Strategy for handling missing values (drop, fill, forward, backward, mean, median, mode) | drop |
| value | No | Value to use when strategy is 'fill' | |
| columns | No | Columns to process (None = all columns) |
Input Schema (JSON Schema)
{
"properties": {
"columns": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Columns to process (None = all columns)"
},
"strategy": {
"default": "drop",
"description": "Strategy for handling missing values (drop, fill, forward, backward, mean, median, mode)",
"enum": [
"drop",
"fill",
"forward",
"backward",
"mean",
"median",
"mode"
],
"type": "string"
},
"value": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Value to use when strategy is 'fill'"
}
},
"type": "object"
}