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
प्रश्न
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 of200for all doctors. - To display rows with index
2and3. - To delete the column
‘Department’.
कोड लेखन
Advertisements
उत्तर
Doctor.tail(3)Doctor[‘Name’]Doctor[‘Discount’] = 200Doctor.loc[[2, 3]]Doctor = Doctor.drop(columns=[‘Department’])
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2024-2025 (March) Set 4
