From c36f8a20bca4867493ca1a91a8513e05e6b764ce Mon Sep 17 00:00:00 2001 From: Stijn Van Hoey Date: Sat, 10 Mar 2018 10:15:41 +0100 Subject: [PATCH] DOC: Extend docstring pandas core index to_frame method (#20036) --- pandas/core/indexes/base.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 69a07a91838e12..7e6ae88a26e7cf 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1148,7 +1148,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