Reading Json file as Pandas Dataframe error

前端 未结 4 1947
小鲜肉
小鲜肉 2020-12-14 02:33

I have a Json file as follows. It\'s a list of dicts.

[{\"city\": \"ab\", \"trips\": 4, \"date\": \"2014-01-25\", \"value\": 4.7, \"price\": 1.1, \"request_         


        
4条回答
  •  感情败类
    2020-12-14 03:15

    The following worked for me when pd.read_json failed: open file, load with normal json.load, then load into a pandas dataframe.

        import pandas as pd
        import json
    
        openfile=open('file.json')
        jsondata=json.load(openfile)
        df=pd.DataFrame(jsondata)
    
        openfile.close()
        print(df)
    

提交回复
热议问题