Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.tail#

DataFrame.tail(n=5)[source]#

Return the lastn rows.

This function returns lastn rows from the object based onposition. It is useful for quickly verifying data, for example,after sorting or appending rows.

For negative values ofn, this function returns all rows exceptthe first|n| rows, equivalent todf[|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:
type of caller

The lastn rows of the caller object.

See also

DataFrame.head

The firstn rows of the caller object.

Examples

>>>df=pd.DataFrame({'animal':['alligator','bee','falcon','lion',...'monkey','parrot','shark','whale','zebra']})>>>df      animal0  alligator1        bee2     falcon3       lion4     monkey5     parrot6      shark7      whale8      zebra

Viewing the last 5 lines

>>>df.tail()   animal4  monkey5  parrot6   shark7   whale8   zebra

Viewing the lastn lines (three in this case)

>>>df.tail(3)  animal6  shark7  whale8  zebra

For negative values ofn

>>>df.tail(-3)   animal3    lion4  monkey5  parrot6   shark7   whale8   zebra

[8]ページ先頭

©2009-2025 Movatter.jp