# dask.dataframe.DataFrame.drop

#### DataFrame.drop(labels=None, axis=0, columns=None, errors='raise')

Drop specified labels from rows or columns.

This docstring was copied from pandas.DataFrame.drop.

Some inconsistencies with the Dask version may exist.

Remove rows or columns by specifying label names and corresponding
axis, or by directly specifying index or column names. When using a
multi-index, labels on different levels can be removed by specifying
the level. See the [user guide](https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html#advanced-shown-levels)
for more information about the now unused levels.

* **Parameters:**
  **labels**
  : Index or column labels to drop. A tuple will be used as a single
    label and not treated as an iterable.

  **axis**
  : Whether to drop labels from the index (0 or ‘index’) or
    columns (1 or ‘columns’).

  **index**
  : Alternative to specifying axis (`labels, axis=0`
    is equivalent to `index=labels`).

  **columns**
  : Alternative to specifying axis (`labels, axis=1`
    is equivalent to `columns=labels`).

  **level**
  : For MultiIndex, level from which the labels will be removed.

  **inplace**
  : If False, return a copy. Otherwise, do operation
    in place and return None.
    <br/>
    #### Deprecated
    Deprecated since version 3.1.0: This keyword is deprecated and will be removed in pandas 4.0.
    See the [whatsnew note on PDEP-8](https://pandas.pydata.org/docs/dev/whatsnew/v3.1.0.html#deprecation-inplace)
    for more details.

  **errors**
  : If ‘ignore’, suppress error and only existing labels are
    dropped.
* **Returns:**
  DataFrame or None
  : Returns DataFrame or None DataFrame with the specified
    index or column labels removed or None if inplace=True.
* **Raises:**
  KeyError
  : If any of the labels is not found in the selected axis.

#### SEE ALSO
[`DataFrame.loc`](dask.dataframe.DataFrame.loc.html.md#dask.dataframe.DataFrame.loc)
: Label-location based indexer for selection by label.

[`DataFrame.dropna`](dask.dataframe.DataFrame.dropna.html.md#dask.dataframe.DataFrame.dropna)
: Return DataFrame with labels on given axis omitted where (all or any) data are missing.

[`DataFrame.drop_duplicates`](dask.dataframe.DataFrame.drop_duplicates.html.md#dask.dataframe.DataFrame.drop_duplicates)
: Return DataFrame with duplicate rows removed, optionally only considering certain columns.

`Series.drop`
: Return Series with specified index labels removed.

### Examples

```pycon
>>> df = pd.DataFrame(np.arange(12).reshape(3, 4), columns=["A", "B", "C", "D"])
>>> df
   A  B   C   D
0  0  1   2   3
1  4  5   6   7
2  8  9  10  11
```

Drop columns

```pycon
>>> df.drop(["B", "C"], axis=1)
   A   D
0  0   3
1  4   7
2  8  11
```

```pycon
>>> df.drop(columns=["B", "C"])
   A   D
0  0   3
1  4   7
2  8  11
```

Drop a row by index

```pycon
>>> df.drop([0, 1])
   A  B   C   D
2  8  9  10  11
```

Drop columns and/or rows of MultiIndex DataFrame

```pycon
>>> midx = pd.MultiIndex(
...     levels=[["llama", "cow", "falcon"], ["speed", "weight", "length"]],
...     codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2], [0, 1, 2, 0, 1, 2, 0, 1, 2]],
... )
>>> df = pd.DataFrame(
...     index=midx,
...     columns=["big", "small"],
...     data=[
...         [45, 30],
...         [200, 100],
...         [1.5, 1],
...         [30, 20],
...         [250, 150],
...         [1.5, 0.8],
...         [320, 250],
...         [1, 0.8],
...         [0.3, 0.2],
...     ],
... )
>>> df
                big     small
llama   speed   45.0    30.0
        weight  200.0   100.0
        length  1.5     1.0
cow     speed   30.0    20.0
        weight  250.0   150.0
        length  1.5     0.8
falcon  speed   320.0   250.0
        weight  1.0     0.8
        length  0.3     0.2
```

Drop a specific index combination from the MultiIndex
DataFrame, i.e., drop the combination `'falcon'` and
`'weight'`, which deletes only the corresponding row

```pycon
>>> df.drop(index=("falcon", "weight"))
                big     small
llama   speed   45.0    30.0
        weight  200.0   100.0
        length  1.5     1.0
cow     speed   30.0    20.0
        weight  250.0   150.0
        length  1.5     0.8
falcon  speed   320.0   250.0
        length  0.3     0.2
```

```pycon
>>> df.drop(index="cow", columns="small")
                big
llama   speed   45.0
        weight  200.0
        length  1.5
falcon  speed   320.0
        weight  1.0
        length  0.3
```

```pycon
>>> df.drop(index="length", level=1)
                big     small
llama   speed   45.0    30.0
        weight  200.0   100.0
cow     speed   30.0    20.0
        weight  250.0   150.0
falcon  speed   320.0   250.0
        weight  1.0     0.8
```

<!-- !! processed by numpydoc !! -->
