美文网首页
把Python Dict类型的键值对转换成DataFrame.c

把Python Dict类型的键值对转换成DataFrame.c

作者: DebugWorld | 来源:发表于2022-09-01 14:59 被阅读0次

    把Python Dict类型的键值对转换成DataFrame.column

    import pandas as pd
    
    
    pd.set_option('display.width', 5000)            # pd展示的宽度
    pd.set_option('display.max_rows', None)         # pd展示所有行数,不省略row
    pd.set_option('display.max_columns', None)      # pd展示所有列,不省略column
    
    data_list = [
        {
            "author": "张三",
            "biblio": {
                "volume": 68,
                "month": "January",
                "name": "Janos Kornai",
                "issue": "s",
                "year": "2018",
                "pages": "27-52",
                "doi": ""
            }
        },
        {
            "author": "李四",
            "biblio": {
                "c_date": "2017",
                "number": "23608",
                "name": "Measuring"
            }
        }
    ]
    print(pd.DataFrame(data_list))
    print(pd.json_normalize(data_list))
    
    结果.png

    相关文章

      网友评论

          本文标题:把Python Dict类型的键值对转换成DataFrame.c

          本文链接:https://www.haomeiwen.com/subject/bhksnrtx.html