A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/docs/dev/user_guide/../reference/api/pandas.DataFrame.head.html below:

pandas.DataFrame.head — pandas 3.0.0.dev0+2231.g4f2aa4d2be documentation

pandas.DataFrame.head#
DataFrame.head(n=5)[source]#

Return the first n rows.

This function exhibits the same behavior as df[:n], returning the first n rows based on position. It is useful for quickly checking if your object has the right type of data in it.

When n is positive, it returns the first n rows. For n equal to 0, it returns an empty object. When n is negative, it returns all rows except the last |n| rows, mirroring the behavior of df[:n].

If n is larger than the number of rows, this function returns all rows.

Parameters:
nint, default 5

Number of rows to select.

Returns:
same type as caller

The first n rows of the caller object.

Examples

>>> df = pd.DataFrame(
...     {
...         "animal": [
...             "alligator",
...             "bee",
...             "falcon",
...             "lion",
...             "monkey",
...             "parrot",
...             "shark",
...             "whale",
...             "zebra",
...         ]
...     }
... )
>>> df
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot
6      shark
7      whale
8      zebra

Viewing the first 5 lines

>>> df.head()
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey

Viewing the first n lines (three in this case)

>>> df.head(3)
      animal
0  alligator
1        bee
2     falcon

For negative values of n

>>> df.head(-3)
      animal
0  alligator
1        bee
2     falcon
3       lion
4     monkey
5     parrot

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4