Hello friends!!!!!
head() - function
Python - pandas
PYTHON
11/27/20241 min read
# creating a random table and head
# head() - This method helps the user to print first few rows of the data frame along with columns.
import pandas as pd
import numpy as np
v = { 'ID' : np.arange(11851,11901) , 'Fee' : np.random.choice(['100000','360000','600000'], size = 50) , ' Class' : np.random.choice(['A','B','D','AA','AB'], size = 50) , ' Transport' : np.random.choice(['Bus','Bike','Car','Hostel'], size = 50) }
df = pd.DataFrame(v,index = np.arange(1,51))
print(df.head(20))
Output:
ID Fee Class Transport
1 11851 360000 AA Bike
2 11852 600000 AB Car
3 11853 100000 A Hostel
4 11854 600000 B Car
5 11855 360000 D Car
6 11856 600000 A Bike
7 11857 600000 AB Car
8 11858 360000 B Bike
9 11859 100000 AA Bus
10 11860 100000 AB Bus
11 11861 600000 AB Bike
12 11862 600000 D Bike
13 11863 360000 A Bike
14 11864 100000 AB Hostel
15 11865 100000 A Car
16 11866 100000 A Bike
17 11867 360000 D Bus
18 11868 360000 AB Bus
19 11869 360000 AA Bus
20 11870 360000 AB Car
=== Code Execution Successful ===