---
title: "Table"
sidebar_label: "Table"
description: "Kotlin binding reference: Table."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Table](index.md)

# Table

[common]\
class [Table](index.md)

A columnar frame: an ordered set of named, typed columns sharing one row count. Build one with [create](Companion/create.md) and [addColumn](addColumn.md) / [addStringColumn](addStringColumn.md) or read a CSV; read a column back as a tensor or a cell by row and column; the verbs ([select](select.md), [head](head.md), [sortBy](sortBy.md), [filter](filter.md), [groupBy](groupBy.md), [join](join.md), ...) each answer a new frame and leave the source unchanged; the in-place operations ([applyScalar](applyScalar.md), [applyColumn](applyColumn.md), [assignColumn](assignColumn.md)) change a column of this frame. `AutoCloseable`: [close](close.md) releases the frame.

```kotlin
Table.create().use { frame ->
    frame.addColumn("score", Tensors.of(floatArrayOf(3f, 1f, 2f), longArrayOf(3)))
    frame.addStringColumn("name", listOf("c", "a", "b"))
    frame.sortBy("score").use { sorted -> sorted.getString(0, "name") }   // "a"
}
```

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Properties

| Name | Summary |
|---|---|
| [columnNames](columnNames.md) | [common]<br>val [columnNames](columnNames.md): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;<br>The column names, in column order. |
| [numColumns](numColumns.md) | [common]<br>val [numColumns](numColumns.md): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The number of columns. |
| [numRows](numRows.md) | [common]<br>val [numRows](numRows.md): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The number of rows. |

## Functions

| Name | Summary |
|---|---|
| [addColumn](addColumn.md) | [common]<br>fun [addColumn](addColumn.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), values: [Tensor](../Tensor/index.md))<br>Append a numeric column from a 1-D CPU tensor (its data copied in); the first column fixes the row count. |
| [addStringColumn](addStringColumn.md) | [common]<br>fun [addStringColumn](addStringColumn.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), values: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;)<br>Append a string column, one value per row. |
| [applyColumn](applyColumn.md) | [common]<br>fun [applyColumn](applyColumn.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), op: [ColumnOp](../ColumnOp/index.md), other: [Tensor](../Tensor/index.md))<br>Apply [op](applyColumn.md) element-wise with another column (read with [column](column.md)) to column [name](applyColumn.md), in place. |
| [applyScalar](applyScalar.md) | [common]<br>fun [applyScalar](applyScalar.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), op: [ColumnOp](../ColumnOp/index.md), scalar: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html))<br>Apply [op](applyScalar.md) with [scalar](applyScalar.md) to every element of column [name](applyScalar.md), in place. |
| [assignColumn](assignColumn.md) | [common]<br>fun [assignColumn](assignColumn.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), values: [Tensor](../Tensor/index.md))<br>Create or replace column [name](assignColumn.md) from a 1-D tensor. |
| [close](close.md) | [common]<br>open fun [close](close.md)() |
| [column](column.md) | [common]<br>fun [column](column.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Tensor](../Tensor/index.md)<br>A numeric column as a 1-D tensor you own (a copy); a missing or string column fails typed. |
| [contains](contains.md) | [common]<br>fun [contains](contains.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True when a column named [name](contains.md) exists. |
| [copy](copy.md) | [common]<br>fun [copy](copy.md)(): [Table](index.md)<br>An independent deep copy of this frame. |
| [filter](filter.md) | [common]<br>fun [filter](filter.md)(mask: [Tensor](../Tensor/index.md)): [Table](index.md)<br>The rows where the boolean [mask](filter.md) (one element per row) is true. |
| [getDouble](getDouble.md) | [common]<br>fun [getDouble](getDouble.md)(row: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)<br>A float column's cell at [row](getDouble.md), widened to a double; a missing column, a null cell or another type fails typed. |
| [getLong](getLong.md) | [common]<br>fun [getLong](getLong.md)(row: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>An integer or boolean column's cell at [row](getLong.md), widened to a long. |
| [getString](getString.md) | [common]<br>fun [getString](getString.md)(row: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>A string column's cell at [row](getString.md). |
| [groupBy](groupBy.md) | [common]<br>fun [groupBy](groupBy.md)(keys: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;, aggs: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[AggSpec](../AggSpec/index.md)&gt;): [Table](index.md)<br>Group by [keys](groupBy.md) and apply [aggs](groupBy.md): one row per group, the key columns then one column per aggregation. |
| [hasNulls](hasNulls.md) | [common]<br>fun [hasNulls](hasNulls.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True when a column carries at least one null cell. |
| [head](head.md) | [common]<br>fun [head](head.md)(n: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = 5): [Table](index.md)<br>A new frame of the first [n](head.md) rows. |
| [isNull](isNull.md) | [common]<br>fun [isNull](isNull.md)(row: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True when the column is absent or the cell at [row](isNull.md) is null (never fails). |
| [join](join.md) | [common]<br>fun [join](join.md)(other: [Table](index.md), on: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;, kind: [JoinKind](../JoinKind/index.md) = JoinKind.INNER): [Table](index.md)<br>An equi-join with [other](join.md) on the [on](join.md) columns, present in both with one type. |
| [nullCount](nullCount.md) | [common]<br>fun [nullCount](nullCount.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The number of null cells in a column. |
| [select](select.md) | [common]<br>fun [select](select.md)(names: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;): [Table](index.md)<br>A new frame holding only [names](select.md), in that order. |
| [slice](slice.md) | [common]<br>fun [slice](slice.md)(offset: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), count: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)): [Table](index.md)<br>A new frame of [count](slice.md) rows from [offset](slice.md). |
| [sortBy](sortBy.md) | [common]<br>fun [sortBy](sortBy.md)(keys: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[SortKey](../SortKey/index.md)&gt;): [Table](index.md)<br>A new frame stably sorted by several keys, most significant first.<br>[common]<br>fun [sortBy](sortBy.md)(column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), order: [SortOrder](../SortOrder/index.md) = SortOrder.ASCENDING): [Table](index.md)<br>A new frame stably sorted by one column. |
| [summary](summary.md) | [common]<br>fun [summary](summary.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The frame rendered as text (a large frame shows its head and tail). |
| [tail](tail.md) | [common]<br>fun [tail](tail.md)(n: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = 5): [Table](index.md)<br>A new frame of the last [n](tail.md) rows. |
| [toCsvString](toCsvString.md) | [common]<br>fun [toCsvString](toCsvString.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The frame as CSV text; [readCsvString](Companion/readCsvString.md) reads it back. |
| [toString](toString.md) | [common]<br>open override fun [toString](toString.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) |
| [unique](unique.md) | [common]<br>fun [unique](unique.md)(column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Table](index.md)<br>The distinct values of a column in first-seen order, as a one-column frame. |
| [valueCounts](valueCounts.md) | [common]<br>fun [valueCounts](valueCounts.md)(column: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Table](index.md)<br>Each distinct non-null value's frequency, as a `value` and `count` frame sorted by count descending. |
| [writeCsv](writeCsv.md) | [common]<br>fun [writeCsv](writeCsv.md)(path: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html))<br>Write the frame as CSV to [path](writeCsv.md). |