modin.pandas.Series.reset_index¶
- Series.reset_index(level=None, *, drop=False, name=_NoDefault.no_default, inplace=False, allow_duplicates=False) Union[DataFrame, Series, None][source]¶
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.
- 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.nameby 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, default False) – 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:
See also
DataFrame.reset_indexAnalogous function for DataFrame.
Examples
Generate a DataFrame with default index.
To specify the name of the new column use name.
To generate a new Series with the default set drop to True.
To update the Series in place, without generating a new one set inplace to True. Note that it also requires
drop=True.The level parameter is interesting for Series with a multi-level index.
To remove a specific level from the Index, use level.
If level is not set, all levels are removed from the Index.