मराठी

Consider the DataFrame df shown below. 0, 1, 2, 3, 4 Name Rohan Sharma, Meera Kapoor, Aarav Singh, Nisha Singh, Aditya Verma Department IT, HR, Finance, Marketing, IT - Informatics Practices

Advertisements
Advertisements

प्रश्न

Consider the DataFrame df shown below.

  Name Department Salary
0 Rohan Sharma IT 75000
1 Meera Kapoor HR 68000
2 Aarav Singh Finance 85000
3 Nisha Singh Marketing 72000
4 Aditya Verma IT 80000

Write Python statements for the following tasks:

  1. Print the last three rows of the DataFrame df.
  2. Add a new column named "Experience" with values [5, 8, 10, 6, 7].
  3. Delete the column "Salary" from the DataFrame.
  4. Rename the column "Department" to "Dept".
  5. Display only the "Name" and "Salary" columns from the DataFrame
कोड लेखन
Advertisements

उत्तर

  1. print(df.tail(3))
  2. df['Experience'] = [5, 8, 10, 6, 7]
  3. df.drop(columns=['Salary'], inplace=True)
  4. df.rename(columns={'Department': 'Dept'}, inplace=True)
  5. print(df[["Name", "Salary"]])
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×