Skip to content

Verb head

head(__data, n=5)

Return the first n rows of the data.

Parameters:

Name Type Description Default
__data

a DataFrame.

required
n

The number of rows of data to keep.

5

Examples:

>>> from siuba import head
>>> from siuba.data import cars
>>> cars >> head(2)
   cyl   mpg   hp
0    6  21.0  110
1    6  21.0  110
Source code in siuba/dply/verbs.py
@singledispatch2(pd.DataFrame)
def head(__data, n = 5):
    """Return the first n rows of the data.

    Parameters
    ----------
    __data:
        a DataFrame.
    n:
        The number of rows of data to keep.

    Examples
    --------

    >>> from siuba import head
    >>> from siuba.data import cars

    >>> cars >> head(2)
       cyl   mpg   hp
    0    6  21.0  110
    1    6  21.0  110
    """

    return __data.head(n)