9951 explained code solutions for 126 technologies


python-pandasHow to create dataframe from indexed JSON


import pandas as pd
json = '''{"id1": {"Phone":"ip5","Price":100},"id2":{"Phone":"ip6","Price":150}}'''
df = pd.read_json(json, orient='index')ctrl + c
import pandas as pd

load Pandas module

.read_json(

will parse specified JSON string and create dataframe

orient='index'

ask Pandas to treat outer keys as indexes