W3cubDocs

/pandas 0.23

pandas.TimedeltaIndex.to_frame

TimedeltaIndex.to_frame(index=True) [source]

Create a DataFrame with a column containing the Index.

New in version 0.21.0.

Parameters:

index : boolean, default True

Set the index of the returned DataFrame as the original Index.

Returns:

DataFrame

DataFrame containing the original Index data.

See also

Index.to_series
Convert an Index to a Series.
Series.to_frame
Convert Series to DataFrame.

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

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.TimedeltaIndex.to_frame.html