pandas.DataFrame.head

Return the first n rows.

This function returns the first n rows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.

param n
int, default 5

Number of rows to select.

return

obj_head : same type as caller The first n rows of the caller object.

Examples

Return the first n rows.

import pandas as pd
from numba import njit


@njit
def dataframe_head():
    df = pd.DataFrame({'animal': ['alligator', 'bee', 'falcon', 'lion',
                                  'monkey', 'parrot', 'shark', 'whale', 'zebra']})

    return df.head(n=6)


print(dataframe_head())
$ python ./dataframe/dataframe_head.py
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot

See also

DataFrame.tail