On this page
pandas.Series.head
Series.head(n=5)[source]-
Return the first
nrows.This function returns the first
nrows for the object based on position. It is useful for quickly testing if your object has the right type of data in it.Parameters: -
n : int, default 5 -
Number of rows to select.
Returns: -
obj_head : same type as caller -
The first
nrows of the caller object.
See also
DataFrame.tail-
Returns the last
nrows.
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 zebraViewing the first 5 lines
>>> df.head() animal 0 alligator 1 bee 2 falcon 3 lion 4 monkeyViewing the first
nlines (three in this case)>>> df.head(3) animal 0 alligator 1 bee 2 falcon -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.Series.head.html