diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index d3a8f11a38715..b96bb22199fa1 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -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