有一个很大的文件 内容是一行一个 MD5 值 我需要统计每个 MD5 出现的次数
如果直接 pandas.read_csv 会 MemoryError
一行一行读+字典 也行 但不是我要的
怎么使用 分块读取 然后分组统计再汇总?
loop = True
chunkSize = 100000
chunks = []
while loop:
try:
chunk = data.get_chunk(chunkSize)
chunks.append(chunk)
except StopIteration:
loop = False
print("Iteration is stopped.")
df = pd.concat(chunks, ignore_index=True)
如果直接 pandas.read_csv 会 MemoryError
一行一行读+字典 也行 但不是我要的
怎么使用 分块读取 然后分组统计再汇总?
loop = True
chunkSize = 100000
chunks = []
while loop:
try:
chunk = data.get_chunk(chunkSize)
chunks.append(chunk)
except StopIteration:
loop = False
print("Iteration is stopped.")
df = pd.concat(chunks, ignore_index=True)