DataFrame的reset_index函数
来源:互联网 发布:数据库基础 编辑:程序博客网 时间:2024/05/18 16:19
notes-pandas-functions
reset_index函数
功能:
示例:
In [1]: dfOut[1]: 0 1 2 3 40 -0.127085 -0.538321 0.641609 -0.020957 0.0035031 -0.304994 0.157213 0.586962 0.251505 1.0224182 -0.239710 1.235562 0.917208 -0.964571 -1.1203313 -0.176416 -0.216204 0.433998 -0.366355 -0.261724# 删除若干行数据In [2]: df1 = df.loc[[0,2,3],:]In [3]: df1Out[3]: 0 1 2 3 40 -0.127085 -0.538321 0.641609 -0.020957 0.0035032 -0.239710 1.235562 0.917208 -0.964571 -1.1203313 -0.176416 -0.216204 0.433998 -0.366355 -0.261724# reset_index,原行索引作为一列保留,列名为indexIn [4]: df2 = df1.reset_index()In [5]: df2Out[5]: index 0 1 2 3 40 0 -0.127085 -0.538321 0.641609 -0.020957 0.0035031 2 -0.239710 1.235562 0.917208 -0.964571 -1.1203312 3 -0.176416 -0.216204 0.433998 -0.366355 -0.261724# reset_index,通过函数 drop=True 删除原行索引In [6]: df3 = df1.reset_index(drop=True)In [7]: df3Out[7]: 0 1 2 3 40 -0.127085 -0.538321 0.641609 -0.020957 0.0035031 -0.239710 1.235562 0.917208 -0.964571 -1.1203312 -0.176416 -0.216204 0.433998 -0.366355 -0.261724
0 0
- DataFrame的reset_index函数
- Spark的DataFrame的窗口函数使用
- pandas中关于set_index和reset_index的用法
- DataFrame自定义函数
- spark dataframe函数编程
- DataFrame.mean()函数
- DataFrame部分函数应用
- Pandas DataFrame 函数方法
- spark DataFrame 的函数|基本操作|集成查询记录
- pandas库中数据结构DataFrame的绘制函数
- DataFrame和numpy中神奇的广播函数
- python dataframe的索引
- pandas.Dataframe 的合并
- DataFrame.loc的区间
- Dataframe的使用方法
- 对pandas重置reset_index()
- Pandas set_index&reset_index
- Github上最流行的pandas,pandas.DataFrame,numpy和scipy函数
- Mybstis XML配置
- xmlhttp的onreadystatechange为什么在send前面
- 反射
- [Easy Connect Naming] 登录ORACLE
- Tensorflow函数:tf.nn.softmax_cross_entropy_with_logits 讲解
- DataFrame的reset_index函数
- MFC不同对话框使用公共数据的几种方法
- Windows10下python2.7安装wxpython
- request.getParameter() 和request.getAttribute() 区别
- ubuntu ssh 连接慢
- xp 无法定位程序输入点 _wfopen_s 于动态链接库 msvcrt.dll 上
- 前端学习笔记,HTML常用标签02
- [BZOJ3033]太鼓达人(欧拉图+dfs)
- 如何获得字符串数组的长度,如:string[] arr