change_column_type
Convert column data types in CSV files to improve data analysis, supporting integer, float, string, boolean, and datetime conversions with error handling options.
Instructions
Change the data type of a column.
Returns: ColumnOperationResult with conversion details
Examples: # Convert string numbers to integers change_column_type(ctx, "age", "int")
# Convert to float, replacing errors with NaN
change_column_type(ctx, "price", "float", errors="coerce")
# Convert to datetime
change_column_type(ctx, "date", "datetime")
# Convert to boolean
change_column_type(ctx, "is_active", "bool")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| column | Yes | Column name to change data type for | |
| dtype | Yes | Target data type (int, float, str, bool, datetime) | |
| errors | No | Error handling: 'raise' for errors, 'coerce' to replace invalid values with NaN | coerce |
Input Schema (JSON Schema)
{
"properties": {
"column": {
"description": "Column name to change data type for",
"type": "string"
},
"dtype": {
"description": "Target data type (int, float, str, bool, datetime)",
"enum": [
"int",
"float",
"str",
"bool",
"datetime"
],
"type": "string"
},
"errors": {
"default": "coerce",
"description": "Error handling: 'raise' for errors, 'coerce' to replace invalid values with NaN",
"enum": [
"raise",
"coerce"
],
"type": "string"
}
},
"required": [
"column",
"dtype"
],
"type": "object"
}