Skip to content

Commit 0e5c9d8

Browse files
DOC: Fix error in pandas.Index.to_series (#34349)
1 parent 64859ec commit 0e5c9d8

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

pandas/core/indexes/base.py

+36-1
Original file line numberDiff line numberDiff line change
@@ -1037,13 +1037,48 @@ def to_series(self, index=None, name=None):
10371037
index : Index, optional
10381038
Index of resulting Series. If None, defaults to original index.
10391039
name : str, optional
1040-
Dame of resulting Series. If None, defaults to name of original
1040+
Name of resulting Series. If None, defaults to name of original
10411041
index.
10421042
10431043
Returns
10441044
-------
10451045
Series
10461046
The dtype will be based on the type of the Index values.
1047+
1048+
See Also
1049+
--------
1050+
Index.to_frame : Convert an Index to a DataFrame.
1051+
Series.to_frame : Convert Series to DataFrame.
1052+
1053+
Examples
1054+
--------
1055+
>>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal')
1056+
1057+
By default, the original Index and original name is reused.
1058+
1059+
>>> idx.to_series()
1060+
animal
1061+
Ant Ant
1062+
Bear Bear
1063+
Cow Cow
1064+
Name: animal, dtype: object
1065+
1066+
To enforce a new Index, specify new labels to ``index``:
1067+
1068+
>>> idx.to_series(index=[0, 1, 2])
1069+
0 Ant
1070+
1 Bear
1071+
2 Cow
1072+
Name: animal, dtype: object
1073+
1074+
To override the name of the resulting column, specify `name`:
1075+
1076+
>>> idx.to_series(name='zoo')
1077+
animal
1078+
Ant Ant
1079+
Bear Bear
1080+
Cow Cow
1081+
Name: zoo, dtype: object
10471082
"""
10481083
from pandas import Series
10491084

0 commit comments

Comments
 (0)