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:
- To print the last three rows of the DataFrame
Doctor. - To display the names of all doctors.
- To add a new column
‘Discount’with value of 200 for all doctors. - To display rows with index
2and3. - To delete the column
‘Department’.
Code Writing
Advertisements
Solution
Doctor.tail(3)Doctor[‘Name’]Doctor[‘Discount’] = 200Doctor.loc[[2, 3]]Doctor = Doctor.drop(columns=[‘Department’])
shaalaa.com
Is there an error in this question or solution?
2024-2025 (March) Set 4
