索引从n开始的 pandas 数据帧
问题说明
是否可以从pandas数据框中的n开始索引?
Is it possible to start the index from n in a pandas dataframe?
我将某些数据集另存为csv文件,并希望使用
I have some datasets saved as csv files, and would like to add the column index with the row number starting from where the last row number ended in the previous file.
例如,对于第一个文件,我使用下面的代码可以正常工作,所以我得到了一个输出的csv文件,其行从1到1048574开始,按预期方式:
For example, for the first file I'm using the following code which works fine, so I got an output csv file with rows starting at 1 to 1048574, as expected:
yellow_jan ['index'] = range(1,len(yellow_jan) 1)
yellow_jan['index'] = range(1, len(yellow_jan) 1)
我想对yellow_feb文件执行相同的操作,但是在1048575处开始行索引,依此类推。
I would like to do same for the yellow_feb file, but starting the row index at 1048575 and so on.
感谢任何帮助!
正确答案
您可以只在结尾处重置索引或定义局部变量,然后在`范围功能。使用读取的每个文件的行数更新变量。
you may just reset the index at the end or define a local variable and use it in `arange' function. update the variable with the numbers of rows for each file you read.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfhaej
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22