1import pandas as pd
2
3#initialize a dataframe
4df = pd.DataFrame(
5 [[21, 72, 67],
6 [23, 78, 62],
7 [32, 74, 56],
8 [73, 88, 67],
9 [32, 74, 56],
10 [43, 78, 69],
11 [32, 74, 54],
12 [52, 54, 76]],
13 columns=['a', 'b', 'c'])
14
15#get first 3 rows
16n=3
17df1 = df.head(n)
18
19#print the dataframe
20print(df1)