Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. [
  2. {
  3. "medication_name": "Victoza",
  4. "medication_id": 68,
  5. "manufacturer_name": "Novo Nordisk",
  6. "practice_id": 1,
  7. "disease_id": 16,
  8. "practice_state": "MA",
  9. "disease_name": "Type II Diabetes",
  10. "practice_name": "Cambridge Hospital Inc"
  11. },
  12. {
  13. "medication_name": "Opsumit",
  14. "medication_id": 39,
  15. "manufacturer_name": "Actelion",
  16. "practice_id": 1,
  17. "disease_id": 12,
  18. "practice_state": "MA",
  19. "disease_name": "Pulmonary Arterial Hypertension",
  20. "practice_name": "Cambridge Hospital Inc"
  21. },
  22. {
  23. "medication_name": "ITCA-650",
  24. "medication_id": 29,
  25. "manufacturer_name": "Intarcia",
  26. "practice_id": 1,
  27. "disease_id": 16,
  28. "practice_state": "MA",
  29. "disease_name": "Type II Diabetes",
  30. "practice_name": "Cambridge Hospital Inc"
  31. },
  32. {
  33. "medication_name": "Flolan",
  34. "medication_id": 22,
  35. "manufacturer_name": "GlaxoSmithKline",
  36. "practice_id": 1,
  37. "disease_id": 12,
  38. "practice_state": "CA",
  39. "disease_name": "Pulmonary Arterial Hypertension",
  40. "practice_name": "Cambridge Hospital Inc"
  41. },
  42. {
  43. "medication_name": "Adcirca",
  44. "medication_id": 4,
  45. "manufacturer_name": "United Therapeutics",
  46. "practice_id": 1,
  47. "disease_id": 12,
  48. "practice_state": "CA",
  49. "disease_name": "Pulmonary Arterial Hypertension",
  50. "practice_name": "Cambridge Hospital Inc"
  51. },
  52. .....
  53. .....
  54. .....
  55. ]
  56.  
  57. {
  58. medication : [ {medication_id : 1, medication_name: "Victoza"}, {medication_id :2, medication_name:"ITCA-650"},....]
  59. practice : [ {practice_id : 1, practice_name: "Cambridge"}, {practice_id : 2, practice_name: "Oxford"},...]
  60. disease : [ {disease_id: 1, disease_name: "Diabetes"}, {disease_id: 2, disease_name: "Obseity"},...]
  61. manufacturer : [{name: "Cipla"}, {name: "Phizer"},...]
  62. state : [{name:"MA"},{name:"CA"},...]
  63. }
  64.  
  65. import pandas as pd
  66.  
  67. df = pd.DataFrame.from_records(data)
  68. # In [38]: df
  69. # Out[38]:
  70. # disease_id disease_name manufacturer_name medication_id medication_name practice_id practice_name practice_state
  71. # 0 16 Type II Diabetes Novo Nordisk 68 Victoza 1 Cambridge Hospital Inc MA
  72. # 1 12 Pulmonary Arterial Hypertension Actelion 39 Opsumit 1 Cambridge Hospital Inc MA
  73. # 2 16 Type II Diabetes Intarcia 29 ITCA-650 1 Cambridge Hospital Inc MA
  74. # 3 12 Pulmonary Arterial Hypertension GlaxoSmithKline 22 Flolan 1 Cambridge Hospital Inc CA
  75. # 4 12 Pulmonary Arterial Hypertension United Therapeutics 4 Adcirca 1 Cambridge Hospital Inc CA
  76.  
  77. res = {}
  78. res['medication'] = df[['medication_id', 'medication_name']].to_dict(orient='records')
  79.  
  80. # In [49]: res
  81. # Out[49]:
  82. # {
  83. # 'medication': [
  84. # {'medication_id': 68, 'medication_name': 'Victoza'},
  85. # {'medication_id': 39, 'medication_name': 'Opsumit'},
  86. # {'medication_id': 29, 'medication_name': 'ITCA-650'},
  87. # {'medication_id': 22, 'medication_name': 'Flolan'},
  88. # {'medication_id': 4, 'medication_name': 'Adcirca'}]
  89. # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement