1、导入相关库
import json
import random
import os
import pandas
2、假设变量df是dataframe格式的数据
3、将df按行存入json文件
filepath=os.path.join('data','train.json')
a=df.to_json(path_or_buf=filepath,orient = 'records',force_ascii=False,lines='orient')
4、按行读取json文件为dataframe格式
df=pandas.read_json(path_or_buf=filepath,orient = 'records',lines='orient')