python - 从特定行开始迭代数据框
问题描述
我的数据框:
dt_object price
0 1990-01-01 00:00:00 1.050067
1 1990-01-01 00:05:00 1.049700
2 1990-01-01 00:10:00 1.049933
3 1990-01-01 00:15:00 1.049733
4 1990-01-01 00:20:00 1.050033
我使用它迭代它
for index, row in df.iterrows():
if index >= 9000000:
#do_the_job
数据文件非常大。我需要从索引 9000000 开始迭代。我可以从这个索引开始迭代一次吗?从 0 到 9000000 的校验需要很长时间才能通过。
我无法将数据从 0 截断到 9000000,因为我正在使用过去的数据进行计算。对于当前行,结果是根据过去的值计算的。
解决方案
您可以对 DataFrame 进行切片:
for index, row in df.iloc[9000000:].iterrows():
pass
推荐阅读
- flutter - 如何在if语句中更改边框颜色?
- python - 如何构造 elm2clu_dict
- regex - 使用正则表达式将字符串分成三部分
- automation - Microsoft Flow - 无法评估模板语言表达式,因为属性“位置”不存在
- nunit - 如何使用 --where for nunit 运行测试用例的子集
- python - 将数据插入到 grakn 模式
- sharepoint-2013 - 使用 SharePoint REST API 将值设置为多值托管元数据字段类型时出错
- python - 为 django 应用程序中的所有用户启用日志条目
- ios - 如何在 Swift 中裁剪图像?
- r - 如何在 R 中为 y_continuous 设置 ylim?