pandas read_json: “If using all scalar values, you must pass an index”

后端 未结 3 892
时光说笑
时光说笑 2020-12-09 15:56

I have some difficulty in importing a JSON file with pandas.

import pandas as pd
map_index_to_word = pd.read_json(\'people_wiki_map_index_to_word.json\')
         


        
3条回答
  •  隐瞒了意图╮
    2020-12-09 16:01

    You can do as @ayhan mention which will give you a column base format

    Or you can enclose the object in [ ] (source) as shown below to give you a row format that will be convenient if you are loading multiple values and planing on using matrix for your machine learning models.

    df = pd.DataFrame([data])
    

提交回复
热议问题