---
title: "prefix(_:)"
framework: tabulardata
role: symbol
role_heading: Instance Method
path: "tabulardata/dataframe/slice/prefix(_:)"
---

# prefix(_:)

Returns a new slice that contains the initial elements of the original slice.

## Declaration

```swift
func prefix(_ length: Int) -> DataFrame.Slice
```

## Parameters

- `length`: The number of elements in the new slice. The length must be greater than or equal to zero and less than or equal to the number of elements in the original slice.

## Return Value

Return Value A new slice of the underlying data frame.

## See Also

### Creating a Slice by Selecting Rows

- [prefix(upTo:)](tabulardata/dataframe/slice/prefix(upto:).md)
- [prefix(through:)](tabulardata/dataframe/slice/prefix(through:).md)
- [suffix(_:)](tabulardata/dataframe/slice/suffix(_:).md)
- [suffix(from:)](tabulardata/dataframe/slice/suffix(from:).md)
