How do I read a large csv file with pandas?

后端 未结 15 1857
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 07:12

I am trying to read a large csv file (aprox. 6 GB) in pandas and i am getting a memory error:

MemoryError                               Traceback (most recen         


        
15条回答
  •  醉话见心
    2020-11-21 07:24

    Solution 1:

    Using pandas with large data

    Solution 2:

    TextFileReader = pd.read_csv(path, chunksize=1000)  # the number of rows per chunk
    
    dfList = []
    for df in TextFileReader:
        dfList.append(df)
    
    df = pd.concat(dfList,sort=False)
    

提交回复
热议问题