# Head and Tail of DataFrame in Pandas

To view a small sample of a Series or DataFrame object, use the head() and tail() methods. The default number of elements to display is five, but you may pass a custom number.

head() returns the first n rows(observe the index values). The default number of elements to display is five, but you may pass a custom number.

tail() returns the last n rows(observe the index values). The default number of elements to display is five, but you may pass a custom number.

Lets start with importing the pandas and numpy

`import pandas as pd`

`import numpy as np`

Create a series with random numbers

`long_series = pd.Series(np.random.randn(1000))`

The first five rows of the data series:

`long_series.head()`

Output:

```
0 0.580156
1 0.469914
2 -0.744791
3 -2.381032
4 0.954909
```

The last three rows of the data series:

long_series.tail(3)

```
997 0.294750
998 -1.108673
999 0.013724
```