Advertisements
Advertisements
Question
Create a DataFrame having 5 rows and write the statement to get the first 4 rows of it.
Code Writing
Advertisements
Solution
import pandas as pd
data = {
'RollNo':,
'Name': ['Amit', 'Bhavna', 'Chetan', 'Divya', 'Esha'],
'Marks': [85, 92, 78, 95, 88]
}
df = pd.DataFrame(data)
print(df.head(4))
head(4) The statement displays the first 4 rows of the DataFrame.
shaalaa.com
Is there an error in this question or solution?
