def xs(self, key: Name, axis: Axis=0, level: Optional[int]=None) -> DataFrameOrSeries:
    "\n        Return cross-section from the DataFrame.\n\n        This method takes a `key` argument to select data at a particular\n        level of a MultiIndex.\n\n        Parameters\n        ----------\n        key : label or tuple of label\n            Label contained in the index, or partially in a MultiIndex.\n        axis : 0 or 'index', default 0\n            Axis to retrieve cross-section on.\n            currently only support 0 or 'index'\n        level : object, defaults to first n levels (n=1 or len(key))\n            In case of a key partially contained in a MultiIndex, indicate\n            which levels are used. Levels can be referred by label or position.\n\n        Returns\n        -------\n        DataFrame or Series\n            Cross-section from the original DataFrame\n            corresponding to the selected index levels.\n\n        See Also\n        --------\n        DataFrame.loc : Access a group of rows and columns\n            by label(s) or a boolean array.\n        DataFrame.iloc : Purely integer-location based indexing\n            for selection by position.\n\n        Examples\n        --------\n        >>> d = {'num_legs': [4, 4, 2, 2],\n        ...      'num_wings': [0, 0, 2, 2],\n        ...      'class': ['mammal', 'mammal', 'mammal', 'bird'],\n        ...      'animal': ['cat', 'dog', 'bat', 'penguin'],\n        ...      'locomotion': ['walks', 'walks', 'flies', 'walks']}\n        >>> df = ps.DataFrame(data=d)\n        >>> df = df.set_index(['class', 'animal', 'locomotion'])\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                                   num_legs  num_wings\n        class  animal  locomotion\n        mammal cat     walks              4          0\n               dog     walks              4          0\n               bat     flies              2          2\n        bird   penguin walks              2          2\n\n        Get values at specified index\n\n        >>> df.xs('mammal')  # doctest: +NORMALIZE_WHITESPACE\n                           num_legs  num_wings\n        animal locomotion\n        cat    walks              4          0\n        dog    walks              4          0\n        bat    flies              2          2\n\n        Get values at several indexes\n\n        >>> df.xs(('mammal', 'dog'))  # doctest: +NORMALIZE_WHITESPACE\n                    num_legs  num_wings\n        locomotion\n        walks              4          0\n\n        >>> df.xs(('mammal', 'dog', 'walks'))  # doctest: +NORMALIZE_WHITESPACE\n        num_legs     4\n        num_wings    0\n        Name: (mammal, dog, walks), dtype: int64\n\n        Get values at specified index and level\n\n        >>> df.xs('cat', level=1)  # doctest: +NORMALIZE_WHITESPACE\n                           num_legs  num_wings\n        class  locomotion\n        mammal walks              4          0\n        "
    from pyspark.pandas.series import first_series
    if (not is_name_like_value(key)):
        raise TypeError("'key' should be a scalar value or tuple that contains scalar values")
    if ((level is not None) and is_name_like_tuple(key)):
        raise KeyError(key)
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    if (not is_name_like_tuple(key)):
        key = (key,)
    if (len(key) > self._internal.index_level):
        raise KeyError('Key length ({}) exceeds index depth ({})'.format(len(key), self._internal.index_level))
    if (level is None):
        level = 0
    rows = [(self._internal.index_spark_columns[lvl] == index) for (lvl, index) in enumerate(key, level)]
    internal = self._internal.with_filter(reduce((lambda x, y: (x & y)), rows))
    if (len(key) == self._internal.index_level):
        psdf: DataFrame = DataFrame(internal)
        pdf = psdf.head(2)._to_internal_pandas()
        if (len(pdf) == 0):
            raise KeyError(key)
        elif (len(pdf) > 1):
            return psdf
        else:
            return first_series(DataFrame(pdf.transpose()))
    else:
        index_spark_columns = (internal.index_spark_columns[:level] + internal.index_spark_columns[(level + len(key)):])
        index_names = (internal.index_names[:level] + internal.index_names[(level + len(key)):])
        index_fields = (internal.index_fields[:level] + internal.index_fields[(level + len(key)):])
        internal = internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields).resolved_copy
        return DataFrame(internal)
Return cross-section from the DataFrame.

This method takes a `key` argument to select data at a particular
level of a MultiIndex.

Parameters
----------
key : label or tuple of label
    Label contained in the index, or partially in a MultiIndex.
axis : 0 or 'index', default 0
    Axis to retrieve cross-section on.
    currently only support 0 or 'index'
level : object, defaults to first n levels (n=1 or len(key))
    In case of a key partially contained in a MultiIndex, indicate
    which levels are used. Levels can be referred by label or position.

Returns
-------
DataFrame or Series
    Cross-section from the original DataFrame
    corresponding to the selected index levels.

See Also
--------
DataFrame.loc : Access a group of rows and columns
    by label(s) or a boolean array.
DataFrame.iloc : Purely integer-location based indexing
    for selection by position.

Examples
--------
>>> d = {'num_legs': [4, 4, 2, 2],
...      'num_wings': [0, 0, 2, 2],
...      'class': ['mammal', 'mammal', 'mammal', 'bird'],
...      'animal': ['cat', 'dog', 'bat', 'penguin'],
...      'locomotion': ['walks', 'walks', 'flies', 'walks']}
>>> df = ps.DataFrame(data=d)
>>> df = df.set_index(['class', 'animal', 'locomotion'])
>>> df  # doctest: +NORMALIZE_WHITESPACE
                           num_legs  num_wings
class  animal  locomotion
mammal cat     walks              4          0
       dog     walks              4          0
       bat     flies              2          2
bird   penguin walks              2          2

Get values at specified index

>>> df.xs('mammal')  # doctest: +NORMALIZE_WHITESPACE
                   num_legs  num_wings
animal locomotion
cat    walks              4          0
dog    walks              4          0
bat    flies              2          2

Get values at several indexes

>>> df.xs(('mammal', 'dog'))  # doctest: +NORMALIZE_WHITESPACE
            num_legs  num_wings
locomotion
walks              4          0

>>> df.xs(('mammal', 'dog', 'walks'))  # doctest: +NORMALIZE_WHITESPACE
num_legs     4
num_wings    0
Name: (mammal, dog, walks), dtype: int64

Get values at specified index and level

>>> df.xs('cat', level=1)  # doctest: +NORMALIZE_WHITESPACE
                   num_legs  num_wings
class  locomotion
mammal walks              4          0
def xs(self, key: Name, axis: Axis=0, level: Optional[int]=None) -> DataFrameOrSeries:
    "\n        Return cross-section from the DataFrame.\n\n        This method takes a `key` argument to select data at a particular\n        level of a MultiIndex.\n\n        Parameters\n        ----------\n        key : label or tuple of label\n            Label contained in the index, or partially in a MultiIndex.\n        axis : 0 or 'index', default 0\n            Axis to retrieve cross-section on.\n            currently only support 0 or 'index'\n        level : object, defaults to first n levels (n=1 or len(key))\n            In case of a key partially contained in a MultiIndex, indicate\n            which levels are used. Levels can be referred by label or position.\n\n        Returns\n        -------\n        DataFrame or Series\n            Cross-section from the original DataFrame\n            corresponding to the selected index levels.\n\n        See Also\n        --------\n        DataFrame.loc : Access a group of rows and columns\n            by label(s) or a boolean array.\n        DataFrame.iloc : Purely integer-location based indexing\n            for selection by position.\n\n        Examples\n        --------\n        >>> d = {'num_legs': [4, 4, 2, 2],\n        ...      'num_wings': [0, 0, 2, 2],\n        ...      'class': ['mammal', 'mammal', 'mammal', 'bird'],\n        ...      'animal': ['cat', 'dog', 'bat', 'penguin'],\n        ...      'locomotion': ['walks', 'walks', 'flies', 'walks']}\n        >>> df = ps.DataFrame(data=d)\n        >>> df = df.set_index(['class', 'animal', 'locomotion'])\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                                   num_legs  num_wings\n        class  animal  locomotion\n        mammal cat     walks              4          0\n               dog     walks              4          0\n               bat     flies              2          2\n        bird   penguin walks              2          2\n\n        Get values at specified index\n\n        >>> df.xs('mammal')  # doctest: +NORMALIZE_WHITESPACE\n                           num_legs  num_wings\n        animal locomotion\n        cat    walks              4          0\n        dog    walks              4          0\n        bat    flies              2          2\n\n        Get values at several indexes\n\n        >>> df.xs(('mammal', 'dog'))  # doctest: +NORMALIZE_WHITESPACE\n                    num_legs  num_wings\n        locomotion\n        walks              4          0\n\n        >>> df.xs(('mammal', 'dog', 'walks'))  # doctest: +NORMALIZE_WHITESPACE\n        num_legs     4\n        num_wings    0\n        Name: (mammal, dog, walks), dtype: int64\n\n        Get values at specified index and level\n\n        >>> df.xs('cat', level=1)  # doctest: +NORMALIZE_WHITESPACE\n                           num_legs  num_wings\n        class  locomotion\n        mammal walks              4          0\n        "
    from pyspark.pandas.series import first_series
    if (not is_name_like_value(key)):
        raise TypeError("'key' should be a scalar value or tuple that contains scalar values")
    if ((level is not None) and is_name_like_tuple(key)):
        raise KeyError(key)
    axis = validate_axis(axis)
    if (axis != 0):
        raise NotImplementedError('axis should be either 0 or "index" currently.')
    if (not is_name_like_tuple(key)):
        key = (key,)
    if (len(key) > self._internal.index_level):
        raise KeyError('Key length ({}) exceeds index depth ({})'.format(len(key), self._internal.index_level))
    if (level is None):
        level = 0
    rows = [(self._internal.index_spark_columns[lvl] == index) for (lvl, index) in enumerate(key, level)]
    internal = self._internal.with_filter(reduce((lambda x, y: (x & y)), rows))
    if (len(key) == self._internal.index_level):
        psdf: DataFrame = DataFrame(internal)
        pdf = psdf.head(2)._to_internal_pandas()
        if (len(pdf) == 0):
            raise KeyError(key)
        elif (len(pdf) > 1):
            return psdf
        else:
            return first_series(DataFrame(pdf.transpose()))
    else:
        index_spark_columns = (internal.index_spark_columns[:level] + internal.index_spark_columns[(level + len(key)):])
        index_names = (internal.index_names[:level] + internal.index_names[(level + len(key)):])
        index_fields = (internal.index_fields[:level] + internal.index_fields[(level + len(key)):])
        internal = internal.copy(index_spark_columns=index_spark_columns, index_names=index_names, index_fields=index_fields).resolved_copy
        return DataFrame(internal)