码迷,mamicode.com
首页 > 其他好文 > 详细

pandas set_index() reset_index()

时间:2018-07-28 00:49:27      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:core   bubuko   ref   generated   class   eset   分享   strong   href   

 

 

set_index() 

官方定义:

使用一个或多个现有列设置索引,   默认情况下生成一个新对象

DataFrame.set_index(keys, drop=True, append=False, inplace=False, verify_integrity=False) 

技术分享图片

单索引:

技术分享图片

复合索引:

技术分享图片

 

 

 reset_index()

DataFrame.reset_index(level=None, drop=False, inplace=False, col_level=0, col_fill=‘‘)

好复杂啊

 http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reset_index.html

 示例:

技术分享图片

技术分享图片

 

pandas set_index() reset_index()

标签:core   bubuko   ref   generated   class   eset   分享   strong   href   

原文地址:https://www.cnblogs.com/bafenqingnian/p/9380360.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!