Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Series
What DataFrames are
DataFrame columns
DataFrame rows
21. Removing a row
Filtering rows and columns
Filtering data frames
Sorting rows
Summary

Instruction

Good job. To delete a row, use dataframe.drop(). It's the same function we used when removing columns. This time, though, we'll use axis=0:

hospitals = hospitals.drop(0, axis=0)

The code above will delete the first row of the hospitals DataFrame.

Note that axis=0 is the default value of drop(), so you can omit it. In that case, the expression becomes very simple:

hospitals = hospitals.drop(0)

By default, drop(...) works with labels. If your index is set to something other than that sequential numbers, you can use index labels in drop(...):

hospitals = hospitals.set_index('Phone Number')
hospitals = hospitals.drop(8643665011)

Exercise

Set Country as the index of eu_states. Next, delete the row with label United Kingdom from the DataFrame.

Stuck? Here's a hint!

To set the index, use:

eu_states = eu_states.set_index('Country')