赞
踩
Pandas读取数据之后使用pandas的head()函数的时候,来观察一下读取的数据
head( )函数只能读取前五行数据如下图所示
在查看这个head()函数的具体实现如下:
- def head(self, n=5):
- """
- Return the first `n` rows.
- This function returns the first `n` rows 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 `n` rows of the caller object.
- See Also
- --------
- DataFrame.tail: Returns the last `n` rows.
- 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
- """
-
- return self.iloc[:n]
从中可以看出默认的时候是查看5行,
如果想输出3行或者多行
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。