mars.dataframe.Index.to_frame#
- Index.to_frame(index: bool = True, name=None)[源代码]#
Create a DataFrame with a column containing the Index.
- 参数
- 返回
DataFrame containing the original Index data.
- 返回类型
参见
Index.to_series
Convert an Index to a Series.
Series.to_frame
Convert Series to DataFrame.
实际案例
>>> import mars.dataframe as md >>> idx = md.Index(['Ant', 'Bear', 'Cow'], name='animal') >>> idx.to_frame().execute() 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).execute() animal 0 Ant 1 Bear 2 Cow
To override the name of the resulting column, specify name:
>>> idx.to_frame(index=False, name='zoo').execute() zoo 0 Ant 1 Bear 2 Cow