AttributeError: 'DataFrame' object has no attribute 'get_chunk' pandas

版权声明:转载请注明作者(独孤尚良dugushangliang)出处: https://blog.csdn.net/dugushangliang/article/details/88050284

 

python利用pandas分块读取文本大文件,发现报错,经对比,我发现我的代码缺少一个关键参数。

dates=pd.read_csv(p1,encoding="utf-8")#, iterator=True)
size=5
df=dates.get_chunk(1)
print(df)
while 1:
    try:
        df=dates.get_chunk(size)
        print(df,"\n")
    except:
        print("——except")
        break

对,就是第一行的iterator=True。

使用chunk来分批次读取size行,前提是读取对象dates要可用iterator。

 

独孤尚良dugushangliang——著

你可能感兴趣的:(#,Pandas,Python)