The Convert Column Types Tab

The Convert Column Types tab allows you to convert column data types. Use this when converting strings to numbers or changing date formats.

Basic Usage

Opening the Type Conversion Tab

  1. Open the Data Table tab
  2. Right-click a column header
  3. Select Convert Column Types...

Configuring Conversion

  1. Select the target data type in the To column dropdown
  2. Select error handling in On Error
  3. Click Preview to review the conversion result
  4. Click Apply to execute the conversion

Type conversion settings

In this example, the bill_length_mm column is being converted from string to float64. The preview table on the right shows the conversion results.

Selecting columns to convert

Auto-detecting Types

Click Auto-detect types to have MIDAS examine the values in each string column and fill the To column with a proposed type. Review the proposals, adjust them if needed, and continue to Preview. Columns that are not string are left unchanged.

Types proposed by Auto-detect

A type is proposed only when every value in the column, excluding missing values, can be interpreted as that type. Strings like NA count as values, not as missing, so columns containing them are not classified and stay string. To convert such columns, select the type manually and choose how to handle unconvertible values in On Error.

Safeguards prevent destructive conversions. Number-like strings with leading zeros, such as postal codes, stay string because converting them would drop the leading zeros. Columns containing integers beyond ±2^53 are not proposed as numeric because the conversion would lose the lower digits. Columns containing only 0 and 1 are detected as int64, not boolean. Columns that parse as dates are detected as datetime if any value has a time other than 00:00:00, and date if all values are at 00:00:00. A value with an explicitly written midnight time, such as 2025-01-15 00:00:00, counts toward date.

Data Types

The data types available in MIDAS are:

Data TypeDescriptionExamples
booleanBoolean valuetrue, false
int64Integer42, -100
float64Decimal3.14, -0.5
dateDate2024-01-15
datetimeDate and time2024-01-15 10:30:00
stringText"Hello", "Tokyo"
<Enum name>Project-defined category set (created via The Manage Enums Tab)species_enum, etc.

Enum types created via The Manage Enums Tab appear in the To dropdown by name (e.g., species_enum). See The Manage Enums Tab for instructions on converting string columns to Enum type.

Which string notations convert to each type follows the CAST rules of DuckDB, the data engine MIDAS runs on. See the DuckDB CAST documentation for the formats accepted as dates or booleans. However, MIDAS strips leading and trailing whitespace before interpretation for conversion to every type, and adds restrictions to integer conversion that prevent value-changing conversions. See Error Handling for details on the integer restrictions.

Error Handling (On Error)

Choose how to handle values that cannot be converted:

OptionDescription
NULLReplace unconvertible values with NULL (missing)
Exclude rowRemove rows containing unconvertible values from the dataset
FailStop processing and show an error if any value cannot be converted

Example: String to Integer Conversion

If the original data contains values like "abc" that cannot be converted to numbers:

  • NULL: "abc" becomes NULL (missing value)
  • Exclude row: The entire row is removed from the dataset
  • Fail: Conversion is aborted and an error message is displayed

For conversion to integer (int64), decimals like "1.5", number-like strings with leading zeros like "007", and integers beyond ±2^53 also count as unconvertible, in addition to non-numeric values like "abc". Values are never silently rounded or stripped of leading zeros.

Preview Feature

Click the Preview button to review conversion results before applying. The preview screen displays the converted data, and in Exclude row mode, rows with conversion errors are highlighted. If everything looks correct, click Apply to execute. If there are issues, click Back to return to settings and make adjustments.

Executing Conversion

When you click Apply, a dialog appears to enter a new dataset name. Enter a name and click OK to create the conversion result as a new dataset.

The original dataset is not modified. Conversion results are always saved as a new Derived Dataset.

Editing a Saved Conversion

Existing converted datasets can be edited. Right-click the dataset in the Project Lineage tab, or select Edit Operation... from the dataset's menu button (⋮) in Project Overview, and Convert Column Types opens in edit mode with the source dataset and conversion settings restored.

In edit mode, if other datasets, models, or reports depend on this dataset, a warning shows the kinds and counts of affected items. Changing the source dataset resets the conversion settings, so configure them again for the new source columns. Click Apply and confirm, and the same dataset is recomputed with the new settings. The dataset name does not change. Derived datasets that depend on this dataset are recomputed the next time their data is needed, and dependent models are re-estimated automatically.

If the transformation is changed from another path such as another edit tab or the Agent API between the time this tab opens and the time you click Apply, MIDAS refuses the save. This keeps the earlier change from being lost without warning. Close the edit tab and choose Edit Operation... again to start over from the current version.

See also