# Slice rows

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

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

Returns a [DataFrame](dataframe.html) with rows at given indices:

```KOTLIN
df
```

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

```KOTLIN
df[0, 3, 4]
```

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

Returns a [DataFrame](dataframe.html) with rows inside given index ranges (including boundary indices):

```KOTLIN
df[1..2]
```

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

```KOTLIN
df[0..2, 4..5]
```

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

## take

Returns a [DataFrame](dataframe.html) containing the first `n` rows.

```KOTLIN
df.take(5)
```

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

If called on a [DataColumn](datacolumn.html), returns a [DataColumn](datacolumn.html) containing its first `n` values.

```KOTLIN
df.age.take(5)
```

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

## takeLast

Returns a [DataFrame](dataframe.html) containing the last `n` rows.

```KOTLIN
df.takeLast(5)
```

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

If called on a [DataColumn](datacolumn.html), returns a [DataColumn](datacolumn.html) containing its last `n` values.

```KOTLIN
df.age.takeLast(5)
```

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

## takeWhile

Returns a [DataFrame](dataframe.html) containing the first rows that satisfy the given [condition](datarow.html#row-conditions).

```KOTLIN
df.takeWhile { isHappy }
```

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

## drop

Returns a [DataFrame](dataframe.html) containing all rows except the first `n` rows.

```KOTLIN
df.drop(5)
```

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

If called on a [DataColumn](datacolumn.html), returns a [DataColumn](datacolumn.html) containing all values of this [DataColumn](datacolumn.html) except the first `n` values.

```KOTLIN
df.age.drop(5)
```

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

## dropLast

Returns a [DataFrame](dataframe.html) containing all rows except the last `n` rows.

```KOTLIN
df.dropLast() // default 1
```

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

```KOTLIN
df.dropLast(5)
```

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

If called on a [DataColumn](datacolumn.html), returns a [DataColumn](datacolumn.html) containing all values of this [DataColumn](datacolumn.html) except the last `n` values.

```KOTLIN
df.age.dropLast(5)
```

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

## dropWhile

Returns a [DataFrame](dataframe.html) containing all rows except the first rows that satisfy the given [condition](datarow.html#row-conditions).

```KOTLIN
df.dropWhile { isHappy }
```

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

