pandas将数据帧写入_json方法替代方案

pandas将数据帧写入_json方法替代方案,json,pandas,dataframe,Json,Pandas,Dataframe,我正在使用以下方法处理一个每小时约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.e

我正在使用以下方法处理一个每小时约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,因为它被送入另一个系统进行拾取/摄取。什么是更快的替代方法?

我注意到在行上迭代通常更快,试试这个:仍然有点慢,但我相信这是更好的。对于IO,您没有什么可以做的,尤其是对于如此大的数据量。时间上有什么不同?它实际上并不快哈哈,至少在这种情况下不是。并排运行代码df.to_json比前面描述的运行循环要快。我在写的地方放了计时器。。哦,好吧。