首页 > 解决方案 > pandas 将数据帧写入 to_json 方法替代

问题描述

我正在使用这个每小时处理大约 400 万行和 50 列的数据框:

    #Write out the file
    try:
        display('Writing {0} '.format(filename))
        df_full.to_json('{0}{1}'.format(output_path,filename),orient='records',lines=True )
    except Exception as e :
        logging.error("Error could not write file", exc_info=True)
        print("Error could not write file")

我这样做是为了简单,但它太慢了。它看起来不像任何 IO 瓶颈,但我必须写出 json,因为它被送入另一个系统进行拾取/摄取。什么是更快的替代方法?

标签: jsonpandasdataframe

解决方案


推荐阅读