def set_index(self, keys: Union[(Name, List[Name])], drop: bool=True, append: bool=False, inplace: bool=False) -> Optional['DataFrame']:
    'Set the DataFrame index (row labels) using one or more existing columns.\n\n        Set the DataFrame index (row labels) using one or more existing\n        columns or arrays (of the correct length). The index can replace the\n        existing index or expand on it.\n\n        Parameters\n        ----------\n        keys : label or array-like or list of labels/arrays\n            This parameter can be either a single column key, a single array of\n            the same length as the calling DataFrame, or a list containing an\n            arbitrary combination of column keys and arrays. Here, "array"\n            encompasses :class:`Series`, :class:`Index` and ``np.ndarray``.\n        drop : bool, default True\n            Delete columns to be used as the new index.\n        append : bool, default False\n            Whether to append columns to existing index.\n        inplace : bool, default False\n            Modify the DataFrame in place (do not create a new object).\n\n        Returns\n        -------\n        DataFrame\n            Changed row labels.\n\n        See Also\n        --------\n        DataFrame.reset_index : Opposite of set_index.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'month\': [1, 4, 7, 10],\n        ...                    \'year\': [2012, 2014, 2013, 2014],\n        ...                    \'sale\': [55, 40, 84, 31]},\n        ...                   columns=[\'month\', \'year\', \'sale\'])\n        >>> df\n           month  year  sale\n        0      1  2012    55\n        1      4  2014    40\n        2      7  2013    84\n        3     10  2014    31\n\n        Set the index to become the \'month\' column:\n\n        >>> df.set_index(\'month\')  # doctest: +NORMALIZE_WHITESPACE\n               year  sale\n        month\n        1      2012    55\n        4      2014    40\n        7      2013    84\n        10     2014    31\n\n        Create a MultiIndex using columns \'year\' and \'month\':\n\n        >>> df.set_index([\'year\', \'month\'])  # doctest: +NORMALIZE_WHITESPACE\n                    sale\n        year  month\n        2012  1     55\n        2014  4     40\n        2013  7     84\n        2014  10    31\n        '
    inplace = validate_bool_kwarg(inplace, 'inplace')
    key_list: List[Label]
    if is_name_like_tuple(keys):
        key_list = [cast(Label, keys)]
    elif is_name_like_value(keys):
        key_list = [(keys,)]
    else:
        key_list = [(key if is_name_like_tuple(key) else (key,)) for key in keys]
    columns = set(self._internal.column_labels)
    for key in key_list:
        if (key not in columns):
            raise KeyError(name_like_string(key))
    if drop:
        column_labels = [label for label in self._internal.column_labels if (label not in key_list)]
    else:
        column_labels = self._internal.column_labels
    if append:
        index_spark_columns = (self._internal.index_spark_columns + [self._internal.spark_column_for(label) for label in key_list])
        index_names = (self._internal.index_names + key_list)
        index_fields = (self._internal.index_fields + [self._internal.field_for(label) for label in key_list])
    else:
        index_spark_columns = [self._internal.spark_column_for(label) for label in key_list]
        index_names = key_list
        index_fields = [self._internal.field_for(label) for label in key_list]
    internal = self._internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields, column_labels=column_labels, data_spark_columns=[self._internal.spark_column_for(label) for label in column_labels], data_fields=[self._internal.field_for(label) for label in column_labels])
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)
Set the DataFrame index (row labels) using one or more existing columns.

Set the DataFrame index (row labels) using one or more existing
columns or arrays (of the correct length). The index can replace the
existing index or expand on it.

Parameters
----------
keys : label or array-like or list of labels/arrays
    This parameter can be either a single column key, a single array of
    the same length as the calling DataFrame, or a list containing an
    arbitrary combination of column keys and arrays. Here, "array"
    encompasses :class:`Series`, :class:`Index` and ``np.ndarray``.
drop : bool, default True
    Delete columns to be used as the new index.
append : bool, default False
    Whether to append columns to existing index.
inplace : bool, default False
    Modify the DataFrame in place (do not create a new object).

Returns
-------
DataFrame
    Changed row labels.

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

Examples
--------
>>> df = ps.DataFrame({'month': [1, 4, 7, 10],
...                    'year': [2012, 2014, 2013, 2014],
...                    'sale': [55, 40, 84, 31]},
...                   columns=['month', 'year', 'sale'])
>>> df
   month  year  sale
0      1  2012    55
1      4  2014    40
2      7  2013    84
3     10  2014    31

Set the index to become the 'month' column:

>>> df.set_index('month')  # doctest: +NORMALIZE_WHITESPACE
       year  sale
month
1      2012    55
4      2014    40
7      2013    84
10     2014    31

Create a MultiIndex using columns 'year' and 'month':

>>> df.set_index(['year', 'month'])  # doctest: +NORMALIZE_WHITESPACE
            sale
year  month
2012  1     55
2014  4     40
2013  7     84
2014  10    31
def set_index(self, keys: Union[(Name, List[Name])], drop: bool=True, append: bool=False, inplace: bool=False) -> Optional['DataFrame']:
    'Set the DataFrame index (row labels) using one or more existing columns.\n\n        Set the DataFrame index (row labels) using one or more existing\n        columns or arrays (of the correct length). The index can replace the\n        existing index or expand on it.\n\n        Parameters\n        ----------\n        keys : label or array-like or list of labels/arrays\n            This parameter can be either a single column key, a single array of\n            the same length as the calling DataFrame, or a list containing an\n            arbitrary combination of column keys and arrays. Here, "array"\n            encompasses :class:`Series`, :class:`Index` and ``np.ndarray``.\n        drop : bool, default True\n            Delete columns to be used as the new index.\n        append : bool, default False\n            Whether to append columns to existing index.\n        inplace : bool, default False\n            Modify the DataFrame in place (do not create a new object).\n\n        Returns\n        -------\n        DataFrame\n            Changed row labels.\n\n        See Also\n        --------\n        DataFrame.reset_index : Opposite of set_index.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'month\': [1, 4, 7, 10],\n        ...                    \'year\': [2012, 2014, 2013, 2014],\n        ...                    \'sale\': [55, 40, 84, 31]},\n        ...                   columns=[\'month\', \'year\', \'sale\'])\n        >>> df\n           month  year  sale\n        0      1  2012    55\n        1      4  2014    40\n        2      7  2013    84\n        3     10  2014    31\n\n        Set the index to become the \'month\' column:\n\n        >>> df.set_index(\'month\')  # doctest: +NORMALIZE_WHITESPACE\n               year  sale\n        month\n        1      2012    55\n        4      2014    40\n        7      2013    84\n        10     2014    31\n\n        Create a MultiIndex using columns \'year\' and \'month\':\n\n        >>> df.set_index([\'year\', \'month\'])  # doctest: +NORMALIZE_WHITESPACE\n                    sale\n        year  month\n        2012  1     55\n        2014  4     40\n        2013  7     84\n        2014  10    31\n        '
    inplace = validate_bool_kwarg(inplace, 'inplace')
    key_list: List[Label]
    if is_name_like_tuple(keys):
        key_list = [cast(Label, keys)]
    elif is_name_like_value(keys):
        key_list = [(keys,)]
    else:
        key_list = [(key if is_name_like_tuple(key) else (key,)) for key in keys]
    columns = set(self._internal.column_labels)
    for key in key_list:
        if (key not in columns):
            raise KeyError(name_like_string(key))
    if drop:
        column_labels = [label for label in self._internal.column_labels if (label not in key_list)]
    else:
        column_labels = self._internal.column_labels
    if append:
        index_spark_columns = (self._internal.index_spark_columns + [self._internal.spark_column_for(label) for label in key_list])
        index_names = (self._internal.index_names + key_list)
        index_fields = (self._internal.index_fields + [self._internal.field_for(label) for label in key_list])
    else:
        index_spark_columns = [self._internal.spark_column_for(label) for label in key_list]
        index_names = key_list
        index_fields = [self._internal.field_for(label) for label in key_list]
    internal = self._internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields, column_labels=column_labels, data_spark_columns=[self._internal.spark_column_for(label) for label in column_labels], data_fields=[self._internal.field_for(label) for label in column_labels])
    if inplace:
        self._update_internal_frame(internal)
        return None
    else:
        return DataFrame(internal)