# Delete a Column From a Pandas DataFrame in Python

> Use the DataFrame.drop method with axis=1 to remove columns from a Pandas DataFrame, with options for in-place modification or returning a new DataFrame

**URL:** https://sentry.io/answers/delete-a-column-from-a-dataframe-in-python-pandas/

---

## The Problem

How do I delete a column from a Pandas DataFrame?

## The Solution

We can do this using the [`DataFrame.drop`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html) method:

```python
import pandas

# DataFrame with three columns
products = pandas.DataFrame([["apple", 1, 2], ["orange", 3, 4], ["pear", 5, 6]],
                 columns=["product", "cost_price", "sale_price"])
print(products)

# Remove the sale_price column
products = products.drop('sale_price', axis=1)

print(products)
```

This code will print the `products` DataFrame with three columns and then with two columns. We've used the following arguments in our `drop` method call:

1. `'sale_price'` is the label of the column to remove. We can also provide a list of labels to delete multiple columns (e.g. `['cost_price', 'sale_price']`).
2. `axis=1` indicates that we should remove a column (`axis=0` will attempt to remove a row).

Alternatively, you can use `inplace=True` to modify the DataFrame directly without reassignment:

```python
products.drop('sale_price', axis=1, inplace=True)
```

Note that the `inplace` parameter is being deprecated across pandas methods. The reassignment approach shown above is the recommended pattern.

---

*Source: [sentry.io/answers/delete-a-column-from-a-dataframe-in-python-pandas/](https://sentry.io/answers/delete-a-column-from-a-dataframe-in-python-pandas/)*
