Skip to content

DOC: Extend docstring pandas core index to_frame method #20036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
21 changes: 20 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,26 @@ def to_frame(self, index=True):

Returns
-------
DataFrame : a DataFrame containing the original Index data.
DataFrame
DataFrame containing the original Index data.

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

By default, the original Index is reused. To enforce a new Index:

>>> idx.to_frame(index=False)
animal
0 Ant
1 Bear
2 Cow
"""

from pandas import DataFrame
Expand Down