def reset_index(self, level: Optional[Union[(int, Name, Sequence[Union[(int, Name)]])]]=None, drop: bool=False, inplace: bool=False, col_level: int=0, col_fill: str='') -> Optional['DataFrame']:
    "Reset the index, or a level of it.\n\n        For DataFrame with multi-level index, return new DataFrame with labeling information in\n        the columns under the index names, defaulting to 'level_0', 'level_1', etc. if any are None.\n        For a standard index, the index name will be used (if set), otherwise a default 'index' or\n        'level_0' (if 'index' is already taken) will be used.\n\n        Parameters\n        ----------\n        level : int, str, tuple, or list, default None\n            Only remove the given levels from the index. Removes all levels by\n            default.\n        drop : bool, default False\n            Do not try to insert index into dataframe columns. This resets\n            the index to the default integer index.\n        inplace : bool, default False\n            Modify the DataFrame in place (do not create a new object).\n        col_level : int or str, default 0\n            If the columns have multiple levels, determines which level the\n            labels are inserted into. By default it is inserted into the first\n            level.\n        col_fill : object, default ''\n            If the columns have multiple levels, determines how the other\n            levels are named. If None then the index name is repeated.\n\n        Returns\n        -------\n        DataFrame\n            DataFrame with the new index.\n\n        See Also\n        --------\n        DataFrame.set_index : Opposite of reset_index.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame([('bird', 389.0),\n        ...                    ('bird', 24.0),\n        ...                    ('mammal', 80.5),\n        ...                    ('mammal', np.nan)],\n        ...                   index=['falcon', 'parrot', 'lion', 'monkey'],\n        ...                   columns=('class', 'max_speed'))\n        >>> df\n                 class  max_speed\n        falcon    bird      389.0\n        parrot    bird       24.0\n        lion    mammal       80.5\n        monkey  mammal        NaN\n\n        When we reset the index, the old index is added as a column. Unlike pandas, pandas-on-Spark\n        does not automatically add a sequential index. The following 0, 1, 2, 3 are only\n        there when we display the DataFrame.\n\n        >>> df.reset_index()\n            index   class  max_speed\n        0  falcon    bird      389.0\n        1  parrot    bird       24.0\n        2    lion  mammal       80.5\n        3  monkey  mammal        NaN\n\n        We can use the `drop` parameter to avoid the old index being added as\n        a column:\n\n        >>> df.reset_index(drop=True)\n            class  max_speed\n        0    bird      389.0\n        1    bird       24.0\n        2  mammal       80.5\n        3  mammal        NaN\n\n        You can also use `reset_index` with `MultiIndex`.\n\n        >>> index = pd.MultiIndex.from_tuples([('bird', 'falcon'),\n        ...                                    ('bird', 'parrot'),\n        ...                                    ('mammal', 'lion'),\n        ...                                    ('mammal', 'monkey')],\n        ...                                   names=['class', 'name'])\n        >>> columns = pd.MultiIndex.from_tuples([('speed', 'max'),\n        ...                                      ('species', 'type')])\n        >>> df = ps.DataFrame([(389.0, 'fly'),\n        ...                    ( 24.0, 'fly'),\n        ...                    ( 80.5, 'run'),\n        ...                    (np.nan, 'jump')],\n        ...                   index=index,\n        ...                   columns=columns)\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                       speed species\n                         max    type\n        class  name\n        bird   falcon  389.0     fly\n               parrot   24.0     fly\n        mammal lion     80.5     run\n               monkey    NaN    jump\n\n        If the index has multiple levels, we can reset a subset of them:\n\n        >>> df.reset_index(level='class')  # doctest: +NORMALIZE_WHITESPACE\n                 class  speed species\n                          max    type\n        name\n        falcon    bird  389.0     fly\n        parrot    bird   24.0     fly\n        lion    mammal   80.5     run\n        monkey  mammal    NaN    jump\n\n        If we are not dropping the index, by default, it is placed in the top\n        level. We can place it in another level:\n\n        >>> df.reset_index(level='class', col_level=1)  # doctest: +NORMALIZE_WHITESPACE\n                        speed species\n                 class    max    type\n        name\n        falcon    bird  389.0     fly\n        parrot    bird   24.0     fly\n        lion    mammal   80.5     run\n        monkey  mammal    NaN    jump\n\n        When the index is inserted under another level, we can specify under\n        which one with the parameter `col_fill`:\n\n        >>> df.reset_index(level='class', col_level=1,\n        ...                col_fill='species')  # doctest: +NORMALIZE_WHITESPACE\n                      species  speed species\n                        class    max    type\n        name\n        falcon           bird  389.0     fly\n        parrot           bird   24.0     fly\n        lion           mammal   80.5     run\n        monkey         mammal    NaN    jump\n\n        If we specify a nonexistent level for `col_fill`, it is created:\n\n        >>> df.reset_index(level='class', col_level=1,\n        ...                col_fill='genus')  # doctest: +NORMALIZE_WHITESPACE\n                        genus  speed species\n                        class    max    type\n        name\n        falcon           bird  389.0     fly\n        parrot           bird   24.0     fly\n        lion           mammal   80.5     run\n        monkey         mammal    NaN    jump\n        "
    inplace = validate_bool_kwarg(inplace, 'inplace')
    multi_index = (self._internal.index_level > 1)

    def rename(index: int) -> Label:
        if multi_index:
            return ('level_{}'.format(index),)
        elif (('index',) not in self._internal.column_labels):
            return ('index',)
        else:
            return ('level_{}'.format(index),)
    if (level is None):
        new_column_labels = [(name if (name is not None) else rename(i)) for (i, name) in enumerate(self._internal.index_names)]
        new_data_spark_columns = [scol.alias(name_like_string(label)) for (scol, label) in zip(self._internal.index_spark_columns, new_column_labels)]
        new_data_fields = self._internal.index_fields
        index_spark_columns = []
        index_names = []
        index_fields = []
    else:
        if is_list_like(level):
            level = list(cast(Sequence[Union[(int, Name)]], level))
        if (isinstance(level, int) or is_name_like_tuple(level)):
            level_list = [cast(Union[(int, Label)], level)]
        elif is_name_like_value(level):
            level_list = [(level,)]
        else:
            level_list = [(lvl if (isinstance(lvl, int) or is_name_like_tuple(lvl)) else (lvl,)) for lvl in level]
        if all((isinstance(lvl, int) for lvl in level_list)):
            int_level_list = cast(List[int], level_list)
            for lev in int_level_list:
                if (lev >= self._internal.index_level):
                    raise IndexError('Too many levels: Index has only {} level, not {}'.format(self._internal.index_level, (lev + 1)))
            idx = int_level_list
        elif all((is_name_like_tuple(lev) for lev in level_list)):
            idx = []
            for label in cast(List[Label], level_list):
                try:
                    i = self._internal.index_names.index(label)
                    idx.append(i)
                except ValueError:
                    if multi_index:
                        raise KeyError('Level unknown not found')
                    else:
                        raise KeyError('Level unknown must be same as name ({})'.format(name_like_string(self._internal.index_names[0])))
        else:
            raise ValueError('Level should be all int or all string.')
        idx.sort()
        new_column_labels = []
        new_data_spark_columns = []
        new_data_fields = []
        index_spark_columns = self._internal.index_spark_columns.copy()
        index_names = self._internal.index_names.copy()
        index_fields = self._internal.index_fields.copy()
        for i in idx[::(- 1)]:
            name = index_names.pop(i)
            new_column_labels.insert(0, (name if (name is not None) else rename(i)))
            scol = index_spark_columns.pop(i)
            new_data_spark_columns.insert(0, scol.alias(name_like_string(name)))
            new_data_fields.insert(0, index_fields.pop(i).copy(name=name_like_string(name)))
    if drop:
        new_data_spark_columns = []
        new_column_labels = []
        new_data_fields = []
    for label in new_column_labels:
        if (label in self._internal.column_labels):
            raise ValueError('cannot insert {}, already exists'.format(name_like_string(label)))
    if (self._internal.column_labels_level > 1):
        column_depth = len(self._internal.column_labels[0])
        if (col_level >= column_depth):
            raise IndexError('Too many levels: Index has only {} levels, not {}'.format(column_depth, (col_level + 1)))
        if any((((col_level + len(label)) > column_depth) for label in new_column_labels)):
            raise ValueError('Item must have length equal to number of levels.')
        new_column_labels = [tuple(((([col_fill] * col_level) + list(label)) + ([col_fill] * (column_depth - (len(label) + col_level))))) for label in new_column_labels]
    internal = self._internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields, column_labels=(new_column_labels + self._internal.column_labels), data_spark_columns=(new_data_spark_columns + self._internal.data_spark_columns), data_fields=(new_data_fields + self._internal.data_fields))
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)
Reset the index, or a level of it.

For DataFrame with multi-level index, return new DataFrame with labeling information in
the columns under the index names, defaulting to 'level_0', 'level_1', etc. if any are None.
For a standard index, the index name will be used (if set), otherwise a default 'index' or
'level_0' (if 'index' is already taken) will be used.

Parameters
----------
level : int, str, tuple, or list, default None
    Only remove the given levels from the index. Removes all levels by
    default.
drop : bool, default False
    Do not try to insert index into dataframe columns. This resets
    the index to the default integer index.
inplace : bool, default False
    Modify the DataFrame in place (do not create a new object).
col_level : int or str, default 0
    If the columns have multiple levels, determines which level the
    labels are inserted into. By default it is inserted into the first
    level.
col_fill : object, default ''
    If the columns have multiple levels, determines how the other
    levels are named. If None then the index name is repeated.

Returns
-------
DataFrame
    DataFrame with the new index.

See Also
--------
DataFrame.set_index : Opposite of reset_index.

Examples
--------
>>> df = ps.DataFrame([('bird', 389.0),
...                    ('bird', 24.0),
...                    ('mammal', 80.5),
...                    ('mammal', np.nan)],
...                   index=['falcon', 'parrot', 'lion', 'monkey'],
...                   columns=('class', 'max_speed'))
>>> df
         class  max_speed
falcon    bird      389.0
parrot    bird       24.0
lion    mammal       80.5
monkey  mammal        NaN

When we reset the index, the old index is added as a column. Unlike pandas, pandas-on-Spark
does not automatically add a sequential index. The following 0, 1, 2, 3 are only
there when we display the DataFrame.

>>> df.reset_index()
    index   class  max_speed
0  falcon    bird      389.0
1  parrot    bird       24.0
2    lion  mammal       80.5
3  monkey  mammal        NaN

We can use the `drop` parameter to avoid the old index being added as
a column:

>>> df.reset_index(drop=True)
    class  max_speed
0    bird      389.0
1    bird       24.0
2  mammal       80.5
3  mammal        NaN

You can also use `reset_index` with `MultiIndex`.

>>> index = pd.MultiIndex.from_tuples([('bird', 'falcon'),
...                                    ('bird', 'parrot'),
...                                    ('mammal', 'lion'),
...                                    ('mammal', 'monkey')],
...                                   names=['class', 'name'])
>>> columns = pd.MultiIndex.from_tuples([('speed', 'max'),
...                                      ('species', 'type')])
>>> df = ps.DataFrame([(389.0, 'fly'),
...                    ( 24.0, 'fly'),
...                    ( 80.5, 'run'),
...                    (np.nan, 'jump')],
...                   index=index,
...                   columns=columns)
>>> df  # doctest: +NORMALIZE_WHITESPACE
               speed species
                 max    type
class  name
bird   falcon  389.0     fly
       parrot   24.0     fly
mammal lion     80.5     run
       monkey    NaN    jump

If the index has multiple levels, we can reset a subset of them:

>>> df.reset_index(level='class')  # doctest: +NORMALIZE_WHITESPACE
         class  speed species
                  max    type
name
falcon    bird  389.0     fly
parrot    bird   24.0     fly
lion    mammal   80.5     run
monkey  mammal    NaN    jump

If we are not dropping the index, by default, it is placed in the top
level. We can place it in another level:

>>> df.reset_index(level='class', col_level=1)  # doctest: +NORMALIZE_WHITESPACE
                speed species
         class    max    type
name
falcon    bird  389.0     fly
parrot    bird   24.0     fly
lion    mammal   80.5     run
monkey  mammal    NaN    jump

When the index is inserted under another level, we can specify under
which one with the parameter `col_fill`:

>>> df.reset_index(level='class', col_level=1,
...                col_fill='species')  # doctest: +NORMALIZE_WHITESPACE
              species  speed species
                class    max    type
name
falcon           bird  389.0     fly
parrot           bird   24.0     fly
lion           mammal   80.5     run
monkey         mammal    NaN    jump

If we specify a nonexistent level for `col_fill`, it is created:

>>> df.reset_index(level='class', col_level=1,
...                col_fill='genus')  # doctest: +NORMALIZE_WHITESPACE
                genus  speed species
                class    max    type
name
falcon           bird  389.0     fly
parrot           bird   24.0     fly
lion           mammal   80.5     run
monkey         mammal    NaN    jump
def reset_index(self, level: Optional[Union[(int, Name, Sequence[Union[(int, Name)]])]]=None, drop: bool=False, inplace: bool=False, col_level: int=0, col_fill: str=) -> Optional['DataFrame']:
    "Reset the index, or a level of it.\n\n        For DataFrame with multi-level index, return new DataFrame with labeling information in\n        the columns under the index names, defaulting to 'level_0', 'level_1', etc. if any are None.\n        For a standard index, the index name will be used (if set), otherwise a default 'index' or\n        'level_0' (if 'index' is already taken) will be used.\n\n        Parameters\n        ----------\n        level : int, str, tuple, or list, default None\n            Only remove the given levels from the index. Removes all levels by\n            default.\n        drop : bool, default False\n            Do not try to insert index into dataframe columns. This resets\n            the index to the default integer index.\n        inplace : bool, default False\n            Modify the DataFrame in place (do not create a new object).\n        col_level : int or str, default 0\n            If the columns have multiple levels, determines which level the\n            labels are inserted into. By default it is inserted into the first\n            level.\n        col_fill : object, default \n            If the columns have multiple levels, determines how the other\n            levels are named. If None then the index name is repeated.\n\n        Returns\n        -------\n        DataFrame\n            DataFrame with the new index.\n\n        See Also\n        --------\n        DataFrame.set_index : Opposite of reset_index.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame([('bird', 389.0),\n        ...                    ('bird', 24.0),\n        ...                    ('mammal', 80.5),\n        ...                    ('mammal', np.nan)],\n        ...                   index=['falcon', 'parrot', 'lion', 'monkey'],\n        ...                   columns=('class', 'max_speed'))\n        >>> df\n                 class  max_speed\n        falcon    bird      389.0\n        parrot    bird       24.0\n        lion    mammal       80.5\n        monkey  mammal        NaN\n\n        When we reset the index, the old index is added as a column. Unlike pandas, pandas-on-Spark\n        does not automatically add a sequential index. The following 0, 1, 2, 3 are only\n        there when we display the DataFrame.\n\n        >>> df.reset_index()\n            index   class  max_speed\n        0  falcon    bird      389.0\n        1  parrot    bird       24.0\n        2    lion  mammal       80.5\n        3  monkey  mammal        NaN\n\n        We can use the `drop` parameter to avoid the old index being added as\n        a column:\n\n        >>> df.reset_index(drop=True)\n            class  max_speed\n        0    bird      389.0\n        1    bird       24.0\n        2  mammal       80.5\n        3  mammal        NaN\n\n        You can also use `reset_index` with `MultiIndex`.\n\n        >>> index = pd.MultiIndex.from_tuples([('bird', 'falcon'),\n        ...                                    ('bird', 'parrot'),\n        ...                                    ('mammal', 'lion'),\n        ...                                    ('mammal', 'monkey')],\n        ...                                   names=['class', 'name'])\n        >>> columns = pd.MultiIndex.from_tuples([('speed', 'max'),\n        ...                                      ('species', 'type')])\n        >>> df = ps.DataFrame([(389.0, 'fly'),\n        ...                    ( 24.0, 'fly'),\n        ...                    ( 80.5, 'run'),\n        ...                    (np.nan, 'jump')],\n        ...                   index=index,\n        ...                   columns=columns)\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                       speed species\n                         max    type\n        class  name\n        bird   falcon  389.0     fly\n               parrot   24.0     fly\n        mammal lion     80.5     run\n               monkey    NaN    jump\n\n        If the index has multiple levels, we can reset a subset of them:\n\n        >>> df.reset_index(level='class')  # doctest: +NORMALIZE_WHITESPACE\n                 class  speed species\n                          max    type\n        name\n        falcon    bird  389.0     fly\n        parrot    bird   24.0     fly\n        lion    mammal   80.5     run\n        monkey  mammal    NaN    jump\n\n        If we are not dropping the index, by default, it is placed in the top\n        level. We can place it in another level:\n\n        >>> df.reset_index(level='class', col_level=1)  # doctest: +NORMALIZE_WHITESPACE\n                        speed species\n                 class    max    type\n        name\n        falcon    bird  389.0     fly\n        parrot    bird   24.0     fly\n        lion    mammal   80.5     run\n        monkey  mammal    NaN    jump\n\n        When the index is inserted under another level, we can specify under\n        which one with the parameter `col_fill`:\n\n        >>> df.reset_index(level='class', col_level=1,\n        ...                col_fill='species')  # doctest: +NORMALIZE_WHITESPACE\n                      species  speed species\n                        class    max    type\n        name\n        falcon           bird  389.0     fly\n        parrot           bird   24.0     fly\n        lion           mammal   80.5     run\n        monkey         mammal    NaN    jump\n\n        If we specify a nonexistent level for `col_fill`, it is created:\n\n        >>> df.reset_index(level='class', col_level=1,\n        ...                col_fill='genus')  # doctest: +NORMALIZE_WHITESPACE\n                        genus  speed species\n                        class    max    type\n        name\n        falcon           bird  389.0     fly\n        parrot           bird   24.0     fly\n        lion           mammal   80.5     run\n        monkey         mammal    NaN    jump\n        "
    inplace = validate_bool_kwarg(inplace, 'inplace')
    multi_index = (self._internal.index_level > 1)

    def rename(index: int) -> Label:
        if multi_index:
            return ('level_{}'.format(index),)
        elif (('index',) not in self._internal.column_labels):
            return ('index',)
        else:
            return ('level_{}'.format(index),)
    if (level is None):
        new_column_labels = [(name if (name is not None) else rename(i)) for (i, name) in enumerate(self._internal.index_names)]
        new_data_spark_columns = [scol.alias(name_like_string(label)) for (scol, label) in zip(self._internal.index_spark_columns, new_column_labels)]
        new_data_fields = self._internal.index_fields
        index_spark_columns = []
        index_names = []
        index_fields = []
    else:
        if is_list_like(level):
            level = list(cast(Sequence[Union[(int, Name)]], level))
        if (isinstance(level, int) or is_name_like_tuple(level)):
            level_list = [cast(Union[(int, Label)], level)]
        elif is_name_like_value(level):
            level_list = [(level,)]
        else:
            level_list = [(lvl if (isinstance(lvl, int) or is_name_like_tuple(lvl)) else (lvl,)) for lvl in level]
        if all((isinstance(lvl, int) for lvl in level_list)):
            int_level_list = cast(List[int], level_list)
            for lev in int_level_list:
                if (lev >= self._internal.index_level):
                    raise IndexError('Too many levels: Index has only {} level, not {}'.format(self._internal.index_level, (lev + 1)))
            idx = int_level_list
        elif all((is_name_like_tuple(lev) for lev in level_list)):
            idx = []
            for label in cast(List[Label], level_list):
                try:
                    i = self._internal.index_names.index(label)
                    idx.append(i)
                except ValueError:
                    if multi_index:
                        raise KeyError('Level unknown not found')
                    else:
                        raise KeyError('Level unknown must be same as name ({})'.format(name_like_string(self._internal.index_names[0])))
        else:
            raise ValueError('Level should be all int or all string.')
        idx.sort()
        new_column_labels = []
        new_data_spark_columns = []
        new_data_fields = []
        index_spark_columns = self._internal.index_spark_columns.copy()
        index_names = self._internal.index_names.copy()
        index_fields = self._internal.index_fields.copy()
        for i in idx[::(- 1)]:
            name = index_names.pop(i)
            new_column_labels.insert(0, (name if (name is not None) else rename(i)))
            scol = index_spark_columns.pop(i)
            new_data_spark_columns.insert(0, scol.alias(name_like_string(name)))
            new_data_fields.insert(0, index_fields.pop(i).copy(name=name_like_string(name)))
    if drop:
        new_data_spark_columns = []
        new_column_labels = []
        new_data_fields = []
    for label in new_column_labels:
        if (label in self._internal.column_labels):
            raise ValueError('cannot insert {}, already exists'.format(name_like_string(label)))
    if (self._internal.column_labels_level > 1):
        column_depth = len(self._internal.column_labels[0])
        if (col_level >= column_depth):
            raise IndexError('Too many levels: Index has only {} levels, not {}'.format(column_depth, (col_level + 1)))
        if any((((col_level + len(label)) > column_depth) for label in new_column_labels)):
            raise ValueError('Item must have length equal to number of levels.')
        new_column_labels = [tuple(((([col_fill] * col_level) + list(label)) + ([col_fill] * (column_depth - (len(label) + col_level))))) for label in new_column_labels]
    internal = self._internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields, column_labels=(new_column_labels + self._internal.column_labels), data_spark_columns=(new_data_spark_columns + self._internal.data_spark_columns), data_fields=(new_data_fields + self._internal.data_fields))
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)