<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ColumnSelector",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents14ColumnSelectorV"
  },
  "title" : "ColumnSelector"
}
-->

# ColumnSelector

An operation that applies an estimator to a selection of columns.

```
struct ColumnSelector<Estimator, UnwrappedInput> where Estimator : Estimator, Estimator.Transformer.Input == UnwrappedInput?
```

## Overview

This estimator applies a non-tabular estimator to a selection of columns. Here’s an example of normalizing
numeric values within each column using a [`StandardScaler`](/documentation/CreateMLComponents/StandardScaler):

```
let numericalScaling = ColumnSelector(
    columns: ["volume", "price"],
    estimator: NumericImputer<Float>(.mean)
        .appending(StandardScaler<Float>())
)
```

In most cases, an inputer must handle missing values.

## Topics

### Creating the selection

[`init(columns: [String], estimator: Estimator)`](/documentation/CreateMLComponents/ColumnSelector/init(columns:estimator:))

Creates a select operation with an estimator.

[`init(ColumnSelection, estimator: Estimator)`](/documentation/CreateMLComponents/ColumnSelector/init(_:estimator:))

Creates a select operation with an estimator.

[`init<T>(ColumnSelection, transformer: T)`](/documentation/CreateMLComponents/ColumnSelector/init(_:transformer:))

Creates a select operation with a transformer.

### Getting the properties

[`var columnSelection: ColumnSelection`](/documentation/CreateMLComponents/ColumnSelector/columnSelection)

The column selection strategy.

[`var estimator: Estimator`](/documentation/CreateMLComponents/ColumnSelector/estimator)

The estimator to use on each column.

### Encoding and decoding

[`func encode(ColumnSelector<Estimator, UnwrappedInput>.Transformer, to: inout any EstimatorEncoder) throws`](/documentation/CreateMLComponents/ColumnSelector/encode(_:to:))

Encodes a fitted transformer.

[`func decode(from: inout any EstimatorDecoder) throws -> ColumnSelector<Estimator, UnwrappedInput>.Transformer`](/documentation/CreateMLComponents/ColumnSelector/decode(from:))

Decodes a previously fitted transformer.

### Fitting a transformer

[`func fitted(to: DataFrame, eventHandler: EventHandler?) async throws -> ColumnSelector<Estimator, UnwrappedInput>.Transformer`](/documentation/CreateMLComponents/ColumnSelector/fitted(to:eventHandler:))

Fits a transformer to a data frame

[`typealias Input`](/documentation/CreateMLComponents/ColumnSelector/Input)

[`typealias Output`](/documentation/CreateMLComponents/ColumnSelector/Output)

[`protocol Transformer`](/documentation/CreateMLComponents/Transformer)

A transformer that takes an input and produces an output.

### Default Implementations

[UpdatableTabularEstimator Implementations](/documentation/CreateMLComponents/ColumnSelector/UpdatableTabularEstimator-Implementations)

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`UpdatableTabularEstimator`](/documentation/CreateMLComponents/UpdatableTabularEstimator)

[`Escapable`](/documentation/Swift/Escapable)

[`TabularEstimator`](/documentation/CreateMLComponents/TabularEstimator)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)