pyspark.pandas.MultiIndex.to_series

MultiIndex.to_series(name: Union[Any, Tuple[Any, …], None] = None) → pyspark.pandas.series.Series

Create a Series with both index and values equal to the index keys useful with map for returning an indexer based on an index.

Parameters
namestring, optional

name of resulting Series. If None, defaults to name of original index

Returns
Seriesdtype will be based on the type of the Index values.

Examples

>>> df = ps.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
...                   columns=['dogs', 'cats'],
...                   index=list('abcd'))
>>> df['dogs'].index.to_series()
a    a
b    b
c    c
d    d
dtype: object