Pandas to_csv() slow saving large dataframe

后端 未结 3 2058
攒了一身酷
攒了一身酷 2020-12-17 10:35

I\'m guessing this is an easy fix, but I\'m running into an issue that it\'s taking nearly an hour to save a pandas dataframe to a csv file using the to_csv()

3条回答
  •  囚心锁ツ
    2020-12-17 11:08

    Adding my small insight since the 'gzip' alternative did not work for me - try using to_hdf method. This reduced the write time significantly! (less than a second for a 100MB file - CSV option preformed this in between 30-55 seconds)

    stage.to_hdf(r'path/file.h5', key='stage', mode='w')
    

提交回复
热议问题