English

Create a DataFrame having 5 rows and write the statement to get the first 4 rows of it.

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?
Chapter 2: Data Handling using Pandas - I - Intext Questions [Page 51]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 2 Data Handling using Pandas - I
Intext Questions | Q b) | Page 51
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×