bigframes.geopandas.GeoSeries.reset_index#

GeoSeries.reset_index(level: Hashable | Sequence[Hashable] = None, *, name: str | None = None, drop: bool = False, inplace: bool = False, allow_duplicates: bool | None = None) DataFrame | Series | None#

Generate a new DataFrame or Series with the index reset.

This is useful when the index needs to be treated as a column, or when the index is meaningless and needs to be reset to the default before another operation.

Examples:

>>> s = bpd.Series([1, 2, 3, 4], name='foo',
...                index=['a', 'b', 'c', 'd'])
>>> s.index.name = "idx"
>>> s
idx
a    1
b    2
c    3
d    4
Name: foo, dtype: Int64

Generate a DataFrame with default index.

>>> s.reset_index()
    idx  foo
0     a    1
1     b    2
2     c    3
3     d    4

[4 rows x 2 columns]

To specify the name of the new column use name param.

>>> s.reset_index(name="bar")
    idx   bar
0     a    1
1     b    2
2     c    3
3     d    4

[4 rows x 2 columns]

To generate a new Series with the default index set param drop=True.

>>> s.reset_index(drop=True)
0    1
1    2
2    3
3    4
Name: foo, dtype: Int64
>>> arrays = [np.array(['bar', 'bar', 'baz', 'baz']),
...           np.array(['one', 'two', 'one', 'two'])]
>>> s2 = bpd.Series(
...     range(4), name='foo',
...     index=pd.MultiIndex.from_arrays(arrays,
...                                     names=['a', 'b']))

If level is not set, all levels are removed from the Index.

>>> s2.reset_index()
     a    b  foo
0  bar  one    0
1  bar  two    1
2  baz  one    2
3  baz  two    3

[4 rows x 3 columns]
Parameters:
  • level (int, str, tuple, or list, default optional) – For a Series with a MultiIndex, only remove the specified levels from the index. Removes all levels by default.

  • drop (bool, default False) – Just reset the index, without inserting it as a column in the new DataFrame.

  • name (object, optional) – The name to use for the column containing the original Series values. Uses self.name by default. This argument is ignored when drop is True.

  • inplace (bool, default False) – Modify the Series in place (do not create a new object).

  • allow_duplicates (bool, optional, default None) – Allow duplicate column labels to be created.

Returns:

When drop is False (the default), a DataFrame is returned. The newly created columns will come first in the DataFrame, followed by the original Series values. When drop is True, a Series is returned. In either case, if inplace=True, no value is returned.

Return type:

bigframes.pandas.Series or bigframes.pandas.DataFrame or None