# first

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

Returns the first value in this [DataColumn](datacolumn.html). If the [DataColumn](datacolumn.html) is empty, throws an exception.

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

```KOTLIN
df
```

[Embedded content](./resources/firstOnColumnDf.html)

```KOTLIN
df.name.first() // returns "Alice"
```

If a predicate is specified, returns the first value in this [DataColumn](datacolumn.html) that matches the predicate. Throws an exception if the [DataColumn](datacolumn.html) contains no elements matching the predicate.

```KOTLIN
df.age.first { it > 17 } // returns 20
```

## firstOrNull

Returns the first value in this [DataColumn](datacolumn.html). If the [DataColumn](datacolumn.html) is empty, returns `null`.

Properties:

```KOTLIN
df
    .filter { age > 50 } // df is empty after filtering
    .age
    .firstOrNull() // returns null
```

Strings:

```KOTLIN
df
    .filter { "age"<Int>() > 50 } // df is empty after filtering
    .age
    .firstOrNull() // returns null
```

If a predicate is specified, returns the first value in this [DataColumn](datacolumn.html) that matches the predicate, or `null` if the [DataColumn](datacolumn.html) contains no elements matching the predicate.

```KOTLIN
df.age.firstOrNull { it > 50 } // returns null
```

