A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/pandas-docs/stable/reference/api/../api/pandas.Index.to_series.html below:

pandas.Index.to_series — pandas 2.3.1 documentation

pandas.Index.to_series#
final Index.to_series(index=None, name=None)[source]#

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:
indexIndex, optional

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

namestr, optional

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

Returns:
Series

The dtype will be based on the type of the Index values.

Examples

>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')

By default, the original index and original name is reused.

>>> idx.to_series()
animal
Ant      Ant
Bear    Bear
Cow      Cow
Name: animal, dtype: object

To enforce a new index, specify new labels to index:

>>> idx.to_series(index=[0, 1, 2])
0     Ant
1    Bear
2     Cow
Name: animal, dtype: object

To override the name of the resulting column, specify name:

>>> idx.to_series(name='zoo')
animal
Ant      Ant
Bear    Bear
Cow      Cow
Name: zoo, dtype: object

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4