pandas.DataFrame.reset_index

pandas 3.1.1 · DataFrame · method

Restore a default positional index. Existing index labels can become columns.

Call syntax

DataFrame.reset_index(…) Full signature
DataFrame.reset_index(
    level=None,
    *,
    drop=False,
    inplace=…,
    col_level=0,
    col_fill='',
    allow_duplicates=False,
    names=None,
)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
level Optional
Positional or keyword
Default None
int, str, tuple, or list

Choose an index level by name or integer position.

drop Optional
Keyword only
Default False
bool

Choose whether removed labels or levels are kept as data where supported.

inplace Optional
Keyword only
bool

Choose whether to change the existing object. Where supported, an in-place call typically returns None.

col_level Optional
Keyword only
Default 0
int or str
col_fill Optional
Keyword only
Default ''
object
allow_duplicates Optional
Keyword only
Default False
bool

Choose whether duplicate labels are permitted by the operation.

names Optional
Keyword only
Default None
int, str or 1-dimensional list

Supply explicit names for labels, fields, or levels.

Returns

DataFrame or None