# corr

> For the complete documentation index, see [llms.txt](https://kotlin.github.io/dataframe/llms.txt).

Returns [DataFrame](dataframe.html) with the pairwise correlation between two sets of columns.

API reference: [corr](https://kotlin.github.io/dataframe/api-docs/core/org.jetbrains.kotlinx.dataframe.api/corr.html)

It computes the [Pearson correlation coefficient](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).

```KOTLIN
corr { columns1 }
    .with { columns2 } | .withItself()
```

See [column selectors](columnselectors.html) for how to select the columns for this operation.

To compute pairwise correlation between all columns in the [DataFrame](dataframe.html) use `corr` without arguments:

```KOTLIN
corr()
```

The function is available for numeric- and `Boolean` columns. `Boolean` values are converted into `1` for `true` and `0` for `false`. All other columns are ignored.

If a [ColumnGroup](datacolumn.html#columngroup) instance is passed as the target column for correlation, it will be unpacked into suitable nested columns.

The resulting [DataFrame](dataframe.html) will have `n1` rows and `n2+1` columns, where `n1` and `n2` are the number of columns in `columns1` and `columns2` respectively.

The first column will have the name "column" and will contain names of columns in `columns1`. Other columns will have the same names as in `columns2` and will contain the computed correlation coefficients.

If exactly one [ColumnGroup](datacolumn.html#columngroup) is passed in `columns1`, the first column in the output will have its name.

