Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "medication_name": "Victoza",
- "medication_id": 68,
- "manufacturer_name": "Novo Nordisk",
- "practice_id": 1,
- "disease_id": 16,
- "practice_state": "MA",
- "disease_name": "Type II Diabetes",
- "practice_name": "Cambridge Hospital Inc"
- },
- {
- "medication_name": "Opsumit",
- "medication_id": 39,
- "manufacturer_name": "Actelion",
- "practice_id": 1,
- "disease_id": 12,
- "practice_state": "MA",
- "disease_name": "Pulmonary Arterial Hypertension",
- "practice_name": "Cambridge Hospital Inc"
- },
- {
- "medication_name": "ITCA-650",
- "medication_id": 29,
- "manufacturer_name": "Intarcia",
- "practice_id": 1,
- "disease_id": 16,
- "practice_state": "MA",
- "disease_name": "Type II Diabetes",
- "practice_name": "Cambridge Hospital Inc"
- },
- {
- "medication_name": "Flolan",
- "medication_id": 22,
- "manufacturer_name": "GlaxoSmithKline",
- "practice_id": 1,
- "disease_id": 12,
- "practice_state": "CA",
- "disease_name": "Pulmonary Arterial Hypertension",
- "practice_name": "Cambridge Hospital Inc"
- },
- {
- "medication_name": "Adcirca",
- "medication_id": 4,
- "manufacturer_name": "United Therapeutics",
- "practice_id": 1,
- "disease_id": 12,
- "practice_state": "CA",
- "disease_name": "Pulmonary Arterial Hypertension",
- "practice_name": "Cambridge Hospital Inc"
- },
- .....
- .....
- .....
- ]
- {
- medication : [ {medication_id : 1, medication_name: "Victoza"}, {medication_id :2, medication_name:"ITCA-650"},....]
- practice : [ {practice_id : 1, practice_name: "Cambridge"}, {practice_id : 2, practice_name: "Oxford"},...]
- disease : [ {disease_id: 1, disease_name: "Diabetes"}, {disease_id: 2, disease_name: "Obseity"},...]
- manufacturer : [{name: "Cipla"}, {name: "Phizer"},...]
- state : [{name:"MA"},{name:"CA"},...]
- }
- import pandas as pd
- df = pd.DataFrame.from_records(data)
- # In [38]: df
- # Out[38]:
- # disease_id disease_name manufacturer_name medication_id medication_name practice_id practice_name practice_state
- # 0 16 Type II Diabetes Novo Nordisk 68 Victoza 1 Cambridge Hospital Inc MA
- # 1 12 Pulmonary Arterial Hypertension Actelion 39 Opsumit 1 Cambridge Hospital Inc MA
- # 2 16 Type II Diabetes Intarcia 29 ITCA-650 1 Cambridge Hospital Inc MA
- # 3 12 Pulmonary Arterial Hypertension GlaxoSmithKline 22 Flolan 1 Cambridge Hospital Inc CA
- # 4 12 Pulmonary Arterial Hypertension United Therapeutics 4 Adcirca 1 Cambridge Hospital Inc CA
- res = {}
- res['medication'] = df[['medication_id', 'medication_name']].to_dict(orient='records')
- # In [49]: res
- # Out[49]:
- # {
- # 'medication': [
- # {'medication_id': 68, 'medication_name': 'Victoza'},
- # {'medication_id': 39, 'medication_name': 'Opsumit'},
- # {'medication_id': 29, 'medication_name': 'ITCA-650'},
- # {'medication_id': 22, 'medication_name': 'Flolan'},
- # {'medication_id': 4, 'medication_name': 'Adcirca'}]
- # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement