KnowledgeBoat Logo

Informatics Practices

Consider the DataFrame df shown below.

 MovieIDTitleYearRating
01LAGAAN20018.4
12TAARE ZAMEEN PAR20078.5
233 IDIOTS20098.4
34DANGAL20168.4
45ANDHADHUN20188.3

Write Python statements for the DataFrame df to:

I. Print the first two rows of the DataFrame df.

II. Display titles of all the movies.

III. Remove the column rating.

IV. Display the data of the 'Title' column from indexes 2 to 4 (both included)

V. Rename the column name 'Title' to 'Name'.

Python Pandas

1 Like

Answer

I. print(df.head(2))

II. print(df['Title'])

III. df = df.drop(‘Rating’, axis=1)

IV. print(df.loc[2:4,'Title'])

V. df.rename(columns={'Title':'Name'}, inplace=True)

Answered By

3 Likes


Related Questions