DataFrame 重新设置索引: reindex 和 reset_index 的区别
将两个 DataFrame 拼接后,想要对拼接后的 DataFrame 重新设置索引要用 reset_index 方法,要想让之前的索引消失,传入参数:drop=True。具体事例:
data2017 = pd.read_csv('data\dataset\data20171207.csv', nrows=50, names=['std_mac', 'date', 'ap_mac', 'rss', 'timestamp'])
data2018 = pd.read_csv('data\dataset\data20180309.csv', nrows=50, names=['std_mac', 'date', 'ap_mac', 'rss', 'timestamp'])
test_201718 = pd.concat([data2017, data2018], axis=0)
test_201718 显示的结果中,index 是重复的,0-49,0-49。
要相对整合后的 test_201718 重新设置索引为 0-99,要用下面的语句:
test_201718 = test_201718.reset_index(drop=True)
reindex 方法是在原缩印的基础上,插入新的索引,不能对所有的原索引进行替换。
DataFrame 重新设置索引: reindex 和 reset_index 的区别的更多相关文章
- pandas中DataFrame重置设置索引
在pandas中,经常对数据进行处理 而导致数据索引顺序混乱,从而影响数据读取.插入等. 小笔总结了以下几种重置索引的方法: import pandas as pd import numpy as n ...
- Pandas之Dataframe叠加,排序,统计,重新设置索引
Pandas之Dataframe索引,排序,统计,重新设置索引 一:叠加 import pandas as pd a_list = [df1,df2,df3] add_data = pd.concat ...
- pandas | 如何在DataFrame中通过索引高效获取数据?
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是pandas数据处理专题的第四篇文章,我们一起来聊聊DataFrame中的索引. 上一篇文章当中我们介绍了DataFrame数据结构当 ...
- Python2.7 中文字符编码 & Pycharm utf-8设置、Unicode与utf-8的区别
Python2.7 中文字符编码 & Pycharm utf-8设置.Unicode与utf-8的区别 zoerywzhou@163.com http://www.cnblogs.com/sw ...
- 索引rebuild与rebuild online区别
索引rebuild与rebuild online区别 1.0目的,本篇文档探讨索引rebuild 与 rebuild online的区别 2.0猜测:已有的知识 2.1对索引rebuild重建会对表申 ...
- (转)Sql Server之旅——第八站 复合索引和include索引到底有多大区别?
索引和锁,这两个主题对我们开发工程师来说,非常的重要...只有理解了这两个主题,我们才能写出高质量的sql语句,在之前的博客中,我所说的 索引都是单列索引...当然数据库不可能只认单列索引,还有我这篇 ...
- pandas 排序之 sort_values,reindex,reset_index, sort_index
如果想按照自己的方式排序ind = 行索引data= data[ind] ind = data.sum(axis=1).sort_values(ascending=False).index data ...
- ES数据库重建索引——Reindex(数据迁移)
应用背景: 1.当你的数据量过大,而你的索引最初创建的分片数量不足,导致数据入库较慢的情况,此时需要扩大分片的数量,此时可以尝试使用Reindex. 2.当数据的mapping需要修改,但是大量的数据 ...
- pandas DataFrame(2)-行列索引及值的获取
pandas DataFrame是二维的,所以,它既有列索引,又有行索引 上一篇里只介绍了列索引: import pandas as pd df = pd.DataFrame({'A': [0, 1, ...
随机推荐
- allegro17.2 gerber 步骤
1.Manufacture -> NC -> Drill Customization... 先点击 Auto generate symbols,出来对话框后点击 YES .然后在Symbo ...
- 初尝Spring Cloud Config
1,下载源码 地址https://spring.io/guides/gs/centralized-configuration/ 2,导入工程 解压后分别把Server端与Client端导入到两个Ecl ...
- U面经Prepare: Print Binary Tree With No Two Nodes Share The Same Column
Give a binary tree, elegantly print it so that no two tree nodes share the same column. Requirement: ...
- CF822D 贪心+递推
CF822D [题目链接]CF822D [题目类型]贪心+递推 &题意: 给你n个人,你可以把他们分组,但必须保持每组相等,分组之后每2个人会比赛,比如一组有i个人,那么就要比赛 次,f[i] ...
- jquery的输入框自动补全功能+ajax
jquery的输入框自动补全功能+ajax 2017年05月10日 18:51:39 辣姐什么鬼 阅读数:1461 标签: web前端 更多 个人分类: web前端 内容参考网友文章写成,原博的链 ...
- ubuntu16.04SSH无法连接
提示错误:server responded "algorithm negotiation failed” 解决办法: 修改ssh的配置文件 /etc/ssh/sshd_config文件 在末 ...
- centos7 安装php7,报错cannot get uid for user nginx
- Angular4 组件生命周期
- ng2
angularjs2的环境问题解决了好久. 百度到的答案也是各种各样还解决不了我的问题. 好在这几天经过不断的测试终于给解决了. ERROR in AppModule is not an NgModu ...
- Hive中常用的参数配置
-- 查看当前环境参数配置set -v;-- 重置配置为默认值reset; -- 调整map数-- input的文件大小,集群设置的文件块大小,hive中通过set dfs.block.size;命令 ...