Skip to main content

Convert Column Type Transform

Use Convert Column Type to assign a specific data type to one or more columns. This can correct misidentified types and prepare values for analysis.

Basic Usage​

To convert column types:

  1. Select the Convert Column Type transform from the transform menu.
  2. For each column you want to change: a. Choose the field under Columns. b. Select the new data type from the Convert To dropdown.
  3. Apply the transformation.

Configure and apply Convert Column Type

Configuration Options​

Basic Options​

  • Columns: Choose a column to convert. You can add more columns and set a different type for each one.
  • Convert To: Choose the new type for each selected column:
    • Numeric
    • Text
    • DateTime
    • Categorical
tip

Add another Columns and Convert To pair for each additional column.

Data Types​

Numeric

Numbers used in calculations, including integers and floating-point values.

Best for: Quantities, measurements, and counts.

Text

Character strings, including values that contain numbers but should not be used in calculations.

Best for: Names, descriptions, and codes.

DateTime

Dates and times that you want to sort, calculate with, or analyze over time.

Best for: Dates, timestamps, and time-series data.

Categorical

A limited set of distinct values. Categorical data can use less memory and supports category-specific analysis.

Best for: Classifications, groups, and yes/no values.

Examples​

Example: Adjusting Data Types in a Sales Dataset

Input Dataset:

date_columnseason_columnsales_column
October 10, 2023Fall123.45
10/31/2023Fall234.56
November 15, 2023Fall345.67
12/31/2023Winter678.90

Initial Data Types:

  • date_column: object (string)
  • season_column: object (string)
  • sales_column: object (string)

Configuration:

  • date_column: DateTime
  • season_column: Categorical
  • sales_column: Numeric

Result:

date_columnseason_columnsales_column
2023-10-10Fall123.45
2023-10-31Fall234.56
2023-11-15Fall345.67
2023-12-31Winter678.90

New Data Types:

  • date_column: datetime64[ns]
  • season_column: category
  • sales_column: float64

The transform converts the dates to datetime values, the seasons to categories, and the sales values to numbers.

Best Practices​

  1. Confirm what each column represents before changing its type.
  2. Watch for information loss when converting to a less precise type, such as float to integer.
  3. Check the result for errors or unexpected NaN values.
  4. Consider a categorical type for repeated values in large datasets; it can improve performance.
  5. Use a consistent date format before converting a column to DateTime.

Troubleshooting​

  • Numeric conversion fails: Check for non-numeric characters or inconsistent formatting.
  • DateTime conversion fails: Make sure every date uses a parseable format. Clean inconsistent values first if needed.
  • Too many categories are created: Check whether the column is truly categorical or whether some values should be grouped.