【问题标题】:I'm getting IndexError: list index out of range error in pandas when trying print a huge file尝试打印大文件时出现 IndexError: list index out of range error in pandas
【发布时间】:2020-09-04 08:12:42
【问题描述】:

在尝试打印大文件时出现 IndexError: list index out of range 错误 这是简单的代码。 store_inventory.csv 有 1000+ 行数据,我相信我需要添加一个参数来修复这个错误需要帮助。

import pandas as pd

df = pd.read_csv('store_inventory.csv', names=['StoreNumber', 'Store', 'Store_subnet', 'MDF_subnet'], sep=',', index_col=[0])
print(df.to_dict())

【问题讨论】:

    标签: python pandas


    【解决方案1】:

    如果没有看到数据集的样本,很难提供帮助。 您是否尝试过不使用 index_col=[0]?

    【讨论】:

    • 嘿,谢谢,我已经删除了csv的标题并执行了,现在运行良好。
    猜你喜欢
    • 1970-01-01
    • 2018-02-08
    • 1970-01-01
    • 1970-01-01
    • 2013-04-27
    • 2021-12-26
    • 2021-02-28
    • 2019-02-23
    • 1970-01-01
    相关资源
    最近更新 更多