Signature:
df.set_index(
['keys', 'drop=True', 'append=False', 'inplace=False', 'verify_integrity=False'],
)
Docstring:
Set the DataFrame index (row labels) using one or more existing
columns. By default yields a new object. Parameters
----------
keys : column label or list of column labels / arrays
drop : boolean, default True
Delete columns to be used as the new index
append : boolean, default False
Whether to append columns to existing index
inplace : boolean, default False
Modify the DataFrame in place (do not create a new object)
verify_integrity : boolean, default False
Check the new index for duplicates. Otherwise defer the check until
necessary. Setting to False will improve the performance of this
method Examples
--------
>>> df = pd.DataFrame({'month': [1, 4, 7, 10],
... 'year': [2012, 2014, 2013, 2014],
... 'sale':[55, 40, 84, 31]})
month sale year
0 1 55 2012
1 4 40 2014
2 7 84 2013
3 10 31 2014 Set the index to become the 'month' column: >>> df.set_index('month')
sale year
month
1 55 2012
4 40 2014
7 84 2013
10 31 2014 Create a multi-index using columns 'year' and 'month': >>> df.set_index(['year', 'month'])
sale
year month
2012 1 55
2014 4 40
2013 7 84
2014 10 31 Create a multi-index using a set of values and a column: >>> df.set_index([[1, 2, 3, 4], 'year'])
month sale
year
1 2012 1 55
2 2014 4 40
3 2013 7 84
4 2014 10 31 Returns
-------
dataframe : DataFrame
File: c:\users\lenovo\anaconda3\lib\site-packages\pandas\core\frame.py
Type: method

  

set_index的更多相关文章

  1. pandas功能使用rename, reindex, set_index 详解

    pandas rename 功能 在使用 pandas 的过程中经常会用到修改列名称的问题,会用到 rename 或者 reindex 等功能,每次都需要去查文档 当然经常也可以使用 df.colum ...

  2. set_index() pandas

    set_index DataFrame可以通过set_index方法,可以设置单索引和复合索引. DataFrame.set_index(keys, drop=True, append=False, ...

  3. pandas的set_index和reset_index方法

    import pandas as pd data = pd.DataFrame(np.arange(1,10).reshape(3,3),index=["a","b&qu ...

  4. python pandas.Series&&DataFrame&& set_index&reset_index

    参考CookBook :http://pandas.pydata.org/pandas-docs/stable/cookbook.html Pandas set_index&reset_ind ...

  5. pandas set_index和reset_index的用法

    1.set_index DataFrame可以通过set_index方法,可以设置单索引和复合索引. DataFrame.set_index(keys, drop=True, append=False ...

  6. pandas 之 set_index

    set_index 很有用 http://stackoverflow.com/questions/10457584/redefining-the-index-in-a-pandas-dataframe ...

  7. pandas set_index() reset_index()

    set_index() 官方定义: 使用一个或多个现有列设置索引,   默认情况下生成一个新对象 DataFrame.set_index(keys, drop=True, append=False,  ...

  8. set_index()与reset_index()函数

    一 set_index()函数 1 主要是理解drop和append参数,注意与reset_index()参数的不同. import pandas as pd df = pd.DataFrame({' ...

  9. 区别 |python-pandas库set_index、reset_index用法区别

    1.set_index() 作用:DataFrame可以通过set_index方法,将普通列设置为单索引/复合索引. 格式:DataFrame.set_index(keys, drop=True, a ...

随机推荐

  1. LeetCode 1051. 高度检查器(Height Checker) 28

    1051. 高度检查器 1051. Height Checker 题目描述 学校在拍年度纪念照时,一般要求学生按照 非递减 的高度顺序排列. 请你返回至少有多少个学生没有站在正确位置数量.该人数指的是 ...

  2. docker容器中用户自定bridge网络与默认bridge网络之间的区别

    转载 https://blog.csdn.net/dkfajsldfsdfsd/article/details/79959534

  3. spring boot 初始

    前言 与时俱进是每一个程序员都应该有的意识,当一个Java程序员在当代步遍布的时候,你就行该想到我能多学点什么.可观的是后端的框架是稳定的,它们能够维持更久的时间在应用中,而不用担心技术的更新换代.但 ...

  4. js中引用类型Math一些常用的方法和属性

    js中有一种引用类型叫做Math,和Global属于单体内置对象,里面有一些非常常用的数学方法和数学常量 常用数学常量 Math.E; // 自然对数的底数Math.LN10 10的自然对数 Math ...

  5. Python的运算符和编码

    1.格式化输出 1.有两种方式: 1.1.%的方式 addr = "我家住在%s" % ("黄土高坡") 1.2.format()的方式 addr = &quo ...

  6. Docker简易安装及命令实例

    docker ~ ~ ~ Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中, ...

  7. AttributeError: module 'select' has no attribute 'epoll'

    AttributeError: module 'select' has no attribute 'epoll'   今天乌班图镜像莫名其妙损坏了,只好用Windows写并发TCP服务器的代码.运行后 ...

  8. (转)WEB服务器_IIS配置优化指南

    原文地址:https://www.cnblogs.com/heyuquan/p/deploy-iis-set-performance-guide.html 通常把站点发布到IIS上运行正常后,很少会去 ...

  9. 并发编程-线程-死锁现象-GIL全局锁-线程池

    一堆锁 死锁现象 (重点) 死锁指的是某个资源被占用后,一直得不到释放,导致其他需要这个资源的线程进入阻塞状态. 产生死锁的情况 对同一把互斥锁加了多次 一个共享资源,要访问必须同时具备多把锁,但是这 ...

  10. Java High Level REST Client 使用示例

    概述 ES 在 7.0 版本开始将废弃 TransportClient,8.0 版本开始将完全移除 TransportClient,取而代之的是 High Level REST Client,官方文档 ...