modin.pandas.DatetimeIndex.to_frame¶
- DatetimeIndex.to_frame(index: bool = True, name: Hashable | None = _NoDefault.no_default) modin.pandas.DataFrame [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/modin/plugin/extensions/index.py#L712-L745)¶
Create a
DataFrame
with a column containing the Index.- Parameters:
index (bool, default True) – Set the index of the returned
DataFrame
as the original Index.name (object, defaults to index.name) – The passed name should substitute for the index name (if it has one).
- Returns:
DataFrame
containing the original Index data.- Return type:
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
To override the name of the resulting column, specify name:
>>> idx.to_frame(index=False, name='zoo') zoo 0 Ant 1 Bear 2 Cow