In [2]:
import numpy as np
import pandas as pd
In [3]:
index = pd.date_range('1/1/2019', periods=6)
In [4]:
s = pd.Series(np.random.randn(6), index=['a', 'b', 'c', 'd', 'e','f'])
In [7]:
df = pd.DataFrame(np.random.randn(6, 4), index=index,
                  columns=['P', 'Q', 'R','S'])

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.

In [8]:
long_series = pd.Series(np.random.randn(800))
In [9]:
long_series.head()
Out[9]:
0    1.298944
1   -0.677865
2    0.414972
3    0.318461
4   -0.869943
dtype: float64
In [10]:
long_series.tail(3)
Out[10]:
797    0.374511
798   -0.721997
799    0.587586
dtype: float64
In [8]:
import numpy as np
import pandas as pd
In [9]:
s = pd.Series(np.random.randn(5), index=['white', 'black', 'blue', 'red', 'green'])
In [10]:
df = pd.DataFrame({'color':['white', 'black', 'blue', 'red', 'green']})
In [13]:
df
Out[13]:
color
0 white
1 black
2 blue
3 red
4 green
In [16]:
df.tail(4)
Out[16]:
color
1 black
2 blue
3 red
4 green