尝试此 *** 作仅从
valuesjson中提取列表
import jsonimport astimport pandas as pdmystr = """{'tags': [{'name': 'Temperature1', 'results': [{'attributes': {'Location': ['3rd Floor'], 'Sensor-Serial-Number': ['PT100']}, 'groups': [{'name': 'type', 'type': 'number'}], 'values': [[1460958592800, 24.2, 3], [1460958602800, 24.1, 1], [1460958612800, 23.9, 1], [1460958622800, 24.2, 1], [1460958632800, 24.5, 1], [1460958642800, 24.9, 1], [1460958652800, 24.6, 1], [1460958662800, 24.7, 1], [1460958672800, 24.7, 1]]}], 'stats': {'rawCount': 9}}]}"""val = ast.literal_eval(mystr)val1 = json.loads(json.dumps(val))val2 = val1['tags'][0]['results'][0]['values']print pd.Dataframe(val2, columns=["time", "temperature", "quality"])
结果证明是
time temperature quality0 1460958592800 24.2 31 1460958602800 24.1 12 1460958612800 23.9 13 1460958622800 24.2 14 1460958632800 24.5 15 1460958642800 24.9 16 1460958652800 24.6 17 1460958662800 24.7 18 1460958672800 24.7 1
这是您的数据集表
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)