Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Delete a Row/Column | The Very First Steps
Pandas First Steps

Delete a Row/Column Delete a Row/Column

At times, certain columns may not provide valuable information, making it advantageous to remove them. The pandas library offers the drop() function for this purpose. Let's delve into the function's syntax.

  • index: Specifies the row indexes to be deleted (used when axis=0);
  • columns: Identifies the column names to be deleted (used when axis=1);
  • axis: Choose whether to remove labels from the rows (0) or columns (1). The default is 0.

In this section, we're going to work with a specific DataFrame. Let's examine it.

We notice that the continent column contains numerous empty rows, making it less informative. Consequently, we'll remove it.

Time for some hands-on practice.

Task

We have a DataFrame called audi_cars. Take a close look at the provided dictionary and eliminate the irrelevant column. Give it a try!

Everything was clear?

Section 1. Chapter 9
toggle bottom row
course content

Course Content

Pandas First Steps

Delete a Row/Column Delete a Row/Column

At times, certain columns may not provide valuable information, making it advantageous to remove them. The pandas library offers the drop() function for this purpose. Let's delve into the function's syntax.

  • index: Specifies the row indexes to be deleted (used when axis=0);
  • columns: Identifies the column names to be deleted (used when axis=1);
  • axis: Choose whether to remove labels from the rows (0) or columns (1). The default is 0.

In this section, we're going to work with a specific DataFrame. Let's examine it.

We notice that the continent column contains numerous empty rows, making it less informative. Consequently, we'll remove it.

Time for some hands-on practice.

Task

We have a DataFrame called audi_cars. Take a close look at the provided dictionary and eliminate the irrelevant column. Give it a try!

Everything was clear?

Section 1. Chapter 9
toggle bottom row
some-alt