bigframes.geopandas.GeoSeries.drop#

GeoSeries.drop(labels: Any = None, *, axis: int | str = 0, index: Any = None, columns: Hashable | Iterable[Hashable] = None, level: str | int | None = None) Series#

Return Series with specified index labels removed.

Remove elements of a Series based on specifying the index labels. When using a multi-index, labels on different levels can be removed by specifying the level.

Examples:

>>> s = bpd.Series(data=np.arange(3), index=['A', 'B', 'C'])
>>> s
A    0
B    1
C    2
dtype: Int64

Drop labels B and C:

>>> s.drop(labels=['B', 'C'])
A    0
dtype: Int64

Drop 2nd level label in MultiIndex Series:

>>> 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]])
>>> s = bpd.Series([45, 200, 1.2, 30, 250, 1.5, 320, 1, 0.3],
...               index=midx)
>>> s
llama   speed      45.0
        weight    200.0
        length      1.2
cow     speed      30.0
        weight    250.0
        length      1.5
falcon  speed     320.0
        weight      1.0
        length      0.3
dtype: Float64
>>> s.drop(labels='weight', level=1)
llama   speed      45.0
        length      1.2
cow     speed      30.0
        length      1.5
falcon  speed     320.0
        length      0.3
dtype: Float64
Parameters:
  • labels (single label or list-like) – Index labels to drop.

  • axis – Unused. Parameter needed for compatibility with DataFrame.

  • index – Redundant for application on Series, but ‘index’ can be used instead of ‘labels’.

  • columns – No change is made to the Series; use ‘index’ or ‘labels’ instead.

  • level – For MultiIndex, level for which the labels will be removed.

Returns:

Series with specified index labels removed or None if inplace=True.

Return type:

bigframes.pandas.Series or None

Raises:

KeyError – If none of the labels are found in the index.