DataFrame.tail
DataFrame.tail(n=5)
返回最后n行。
对于n的负值,此函数返回除前n行之外的所有行。
Example
import pandas as pd
df = pd.DataFrame({'site':['google', 'baidu', 'wiki', 'pandas'],
'age':[18, 39, 22, 45],
'price': [1.0, 2.0, 3.0, 4.0],
'color': ['red', 'black', None, 'red']})
df.tail(3)
--------------------------------------------------------
site age price color
1 baidu 39 2.0 black
2 wiki 22 3.0 None
3 pandas 45 4.0 red
Example
import pandas as pd
df = pd.DataFrame({'site':['google', 'baidu', 'wiki', 'pandas'],
'age':[18, 39, 22, 45],
'price': [1.0, 2.0, 3.0, 4.0],
'color': ['red', 'black', None, 'red']})
df.tail(-3)
------------------------------------------------------
site age price color
3 pandas 45 4.0 red