Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Working with Excel Files
Summary
15. Exercise 3

Instruction

Good job! If you'd like to delete a few rows in a worksheet, you need to do it carefully. Say you'd like to remove the third and seventh row. Here's how you should do it:

ws.delete_rows(3)
ws.delete_rows(6)

That's right. After you remove the third row, the seventh row becomes the sixth row. That's why you need to actually remove the sixth row, not the seventh.

Exercise

The products and orders worksheets have the following respective structures:

product_id product_name product_price
client_id product_id

Remove:

  • Rows 2 and 5 from the products worksheet.
  • Rows 2 and 3 from the orders worksheet.

Save the workbook to the final_orders.xlsx file.

We've already loaded a workbook for you and assigned it to the wb variable.

Stuck? Here's a hint!

Remember, if you remove the second row in the products worksheet, the fifth row becomes the fourth row, so you need to romove the fourth row, not the fifth.