Head 和 Tail

To view a small sample of a Series or DataFrame object, use the head() and tail() methods. The default number of elements to display is five, but you may pass a custom number. 使用 head()tail() 方法来只展示一个序列或数据表对象的一个局部。默认的展示元素数量是5,但是你可以传入任意的一个数值。

  1. In [5]: long_series = pd.Series(np.random.randn(1000))
  2. In [6]: long_series.head()
  3. Out[6]:
  4. 0 0.229453
  5. 1 0.304418
  6. 2 0.736135
  7. 3 -0.859631
  8. 4 -0.424100
  9. dtype: float64
  10. In [7]: long_series.tail(3)
  11. Out[7]:
  12. 997 -0.351587
  13. 998 1.136249
  14. 999 -0.448789
  15. dtype: float64