<!--
{
  "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/ColumnConcatenator",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents18ColumnConcatenatorV"
  },
  "title" : "ColumnConcatenator"
}
-->

# ColumnConcatenator

A transformer that concatenates every numerical column in a dataframe into to a shaped array for each row.

```
struct ColumnConcatenator<Scalar> where Scalar : MLShapedArrayScalar, Scalar : BinaryFloatingPoint
```

## Overview

The resulting concatenated column contains `MLShapedArray<Scalar>` elements. For example

```
┏━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┓
┃   ┃ label    ┃ price   ┃ rooms ┃ A     ┃ B     ┃ C     ┃
┃   ┃ <String> ┃ <Int>   ┃ <Int> ┃ <Int> ┃ <Int> ┃ <Int> ┃
┡━━━╇━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━┩
│ 0 │ good     │ 850,000 │     4 │     1 │     0 │     0 │
│ 1 │ bad      │ 700,000 │     3 │     0 │     1 │     0 │
│ 2 │ bad      │ 650,000 │     3 │     0 │     0 │     1 │
│ 3 │ good     │ 600,000 │     2 │     0 │     1 │     0 │
└───┴──────────┴─────────┴───────┴───────┴───────┴───────┘
```

would be concatenated as:

```
┏━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┓
┃   ┃ label    ┃ features               ┃
┃   ┃ <String> ┃ <MLShapedArray<Float>> ┃
┡━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 0 │ good     │ [850,000, 4, 1, 0, 0]  │
│ 1 │ bad      │ [700,000, 3, 0, 1, 0]  │
│ 2 │ bad      │ [650,000, 3, 0, 0, 1]  │
│ 3 │ good     │ [600,000, 2, 0, 1, 0]  │
└───┴──────────┴────────────────────────┘
```

Non-numerical columns are left in the data frame unchanged. Supported numeric types are `Int`, `UInt8`, `Float`,
and `Double`. Arrays and shaped arrays of those types as supported, but every array in a given column must have the
same shape and shaped arrays across columns must have the same shape except for the last dimension.

## Topics

### Creating the concatenator

[`init(columnSelection: ColumnSelection, concatenatedColumnName: String)`](/documentation/CreateMLComponents/ColumnConcatenator/init(columnSelection:concatenatedColumnName:))

Creates a concatenator that concatenates numeric columns into a new column of ML shaped array.

### Getting the properties

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

The selection of columns to concatenate.

[`var concatenatedColumnName: String`](/documentation/CreateMLComponents/ColumnConcatenator/concatenatedColumnName)

The name of the concatenated column containing the shaped arrays.

### Applying

[`func applied(to: DataFrame, eventHandler: EventHandler?) throws -> DataFrame`](/documentation/CreateMLComponents/ColumnConcatenator/applied(to:eventHandler:))

Combines every numerical column in a data frame into to a shaped array for each row.

## Relationships

### Conforms To

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

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

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

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

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

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

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

---

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)