python - Loading json dict into dataframe -


i have json dict formatted so

{"cache_age_milliseconds": 0, "rows": [{"values": [["sonos_hxxpu71ty1g4hwwu2jxcj8tcku", 1483225200000, "87.61.241.100", "*null*"], 0.3605555555555556]}, {"values": [["sonos_hxxpu71ty1g4hwwu2jxcj8tcku", 1483221600000, "87.61.241.100", "*null*"], 0.35888888888888887]}], "columns": [{"type": "array", "label": ["household id", "__hour__", "ip", "serialnumber.config.roomtype"]}, {"type": "number", "label": "measure_value"}]} 

what fastest way load dataframe?

i might wrong here close looking for? because can surely find less dirty way output important here.

import pandas pd  data = {"cache_age_milliseconds": 0, "rows": [{"values": [["sonos_hxxpu71ty1g4hwwu2jxcj8tcku", 1483225200000, "87.61.241.100", "*null*"], 0.3605555555555556]}, {"values": [["sonos_hxxpu71ty1g4hwwu2jxcj8tcku", 1483221600000, "87.61.241.100", "*null*"], 0.35888888888888887]}], "columns": [{"type": "array", "label": ["household id", "__hour__", "ip", "serialnumber.config.roomtype"]}, {"type": "number", "label": "measure_value"}]} df = pd.dataframe.from_dict([i["values"][0] in data["rows"]]) df.columns = data["columns"][0]["label"] df.index = [i["values"][1] in data["rows"]] df.index.name = data["columns"][1]["label"] 

results in this:

                                   household id       __hour__             ip serialnumber.config.roomtype measure_value 0.360556       sonos_hxxpu71ty1g4hwwu2jxcj8tcku  1483225200000  87.61.241.100                       *null* 0.358889       sonos_hxxpu71ty1g4hwwu2jxcj8tcku  1483221600000  87.61.241.100                       *null* 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -