Advertisements
Advertisements
प्रश्न
Consider the DataFrame df shown below.
| MovieID | Title | Year | Rating | |
| 0 | 1 | LAGAAN | 2001 | 8.4 |
| 1 | 2 | TAARE ZAMEEN PAR | 2007 | 8.5 |
| 2 | 3 | 3 IDIOTS | 2009 | 8.4 |
| 3 | 4 | DANGAL | 2016 | 8.4 |
| 4 | 5 | ANDHADHUN | 2018 | 8.3 |
Write Python statements for the DataFrame df to:
- Print the first two rows of the DataFrame df.
- Display titles of all the movies.
- Remove the column rating.
- Display the data of the 'Title' column from indexes 2 to 4 (both included).
- Rename the column name 'Title' to 'Name'.
कोड लेखन
Advertisements
उत्तर
- print(df.head(2))
- print(df['Title'])
- df = df.drop(‘Rating’, axis=1)
- print(df.loc[2:4,'Title'])
- df.rename(columns={'Title':'Name'}, inplace=True)
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
