English

Consider the DataFrame Doctor shown below: 0 1 2 3 4, DID 101 102 103 104 105 Name Dr. Joe Dr. Salma Dr. Jeet Dr. Neha Dr. Vikram Department ENT UROLOGY ORTHO ENT ORTHO Fee 1500 1600 1550 1200 1700

Advertisements
Advertisements

Question

Consider the DataFrame Doctor shown below:

  DID  Name Department Fee
0 101 Dr. Joe ENT 1500
1 102 Dr. Salma UROLOGY 1600
2 103 Dr. Jeet ORTHO 1550
3 104 Dr. Neha ENT 1200
4 105 Dr. Vikram ORTHO 1700

Write suitable Python statements for the following:

  1. To print the last three rows of the DataFrame Doctor.
  2. To display the names of all doctors.
  3. To add a new column ‘Discount’ with value of 200 for all doctors.
  4. To display rows with index 2 and 3.
  5. To delete the column ‘Department’.
Code Writing
Advertisements

Solution

  1. Doctor.tail(3)
  2. Doctor[‘Name’]
  3. Doctor[‘Discount’] = 200
  4. Doctor.loc[[2, 3]]
  5. Doctor = Doctor.drop(columns=[‘Department’])
shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×