change_column_type
Convert column data types in CSV files to int, float, str, bool, or datetime formats 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 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| success | No | Whether operation completed successfully | |
| operation | Yes | Type of operation performed | |
| transform | No | Transform description | |
| part_index | No | Part index for split operations | |
| nulls_filled | No | Number of null values filled | |
| rows_removed | No | Number of rows removed (for remove_duplicates) | |
| rows_affected | Yes | Number of rows affected by operation | |
| values_filled | No | Number of values filled (for fill_missing_values) | |
| updated_sample | No | Sample values after operation | |
| original_sample | No | Sample values before operation | |
| columns_affected | Yes | Names of columns affected |