对于超大规模的csv文件,我们无法一下将其读入内存当中,只能分块一部分一部分的进行读取;

  首先进行如下操作:

import pandas as pd
reader = pd.read_csv('data/servicelogs', iterator=True)

分块,每一块是一个chunk,之后将chunk进行拼接;
loop = True
chunkSize = 100000
chunks = []
while loop:
    try:
        chunk = reader.get_chunk(chunkSize)
        chunks.append(chunk)
    except StopIteration:
        loop = False
        print "Iteration is stopped."
df = pd.concat(chunks, ignore_index=True)

相关文章:

  • 2021-06-15
  • 2021-11-28
猜你喜欢
  • 2021-08-30
  • 2021-08-01
  • 2022-12-23
  • 2021-09-07
  • 2021-11-04
  • 2021-10-22
相关资源
相似解决方案