In [2]:
import pandas as pd
In [3]:
df = pd.read_csv('/home/drcjar/Downloads/T201608PDPI+BNFT.CSV')
In [4]:
df.head()
Out[4]:
SHA
PCT
PRACTICE
BNF CODE
BNF NAME
ITEMS
NIC
ACT COST
QUANTITY
PERIOD
0
Q44
RJN
Y05218
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
1
1.61
1.60
56
201608
1
Q44
RJN
Y05218
0502010B0AAABAB
Fluconazole_Cap 150mg
1
6.64
6.16
8
201608
2
Q44
RJN
Y05218
0703021Q0AAAAAA
Desogestrel_Tab 75mcg
4
7.64
7.13
336
201608
3
Q44
RTV
Y04937
0401010Z0AAAAAA
Zopiclone_Tab 7.5mg
5
2.61
2.98
63
201608
4
Q44
RTV
Y04937
0401020K0AAAIAI
Diazepam_Tab 5mg
2
1.54
1.45
56
201608
In [5]:
practices = pd.read_csv('../refdata/epraccur.csv')
In [6]:
practices.head()
Out[6]:
A81001
THE DENSHAM SURGERY
Y54
Q74
THE HEALTH CENTRE
LAWSON STREET
STOCKTON-ON-TEES
CLEVELAND
Unnamed: 8
TS18 1HU
...
01642 672351
Unnamed: 18
Unnamed: 19
Unnamed: 20
0
Unnamed: 22
00K.1
Unnamed: 24
4
Unnamed: 26
0
A81002
QUEENS PARK MEDICAL CENTRE
Y54
Q74
QUEENS PARK MEDICAL CTR
FARRER STREET
STOCKTON ON TEES
CLEVELAND
NaN
TS18 2AW
...
01642 679681
NaN
NaN
NaN
0
NaN
00K
NaN
4
NaN
1
A81003
VICTORIA MEDICAL PRACTICE
Y54
Q74
THE HEALTH CENTRE
VICTORIA ROAD
HARTLEPOOL
CLEVELAND
NaN
TS26 8DB
...
01429 272945
NaN
NaN
NaN
1
NaN
00K
NaN
4
NaN
2
A81004
WOODLANDS ROAD SURGERY
Y54
Q74
6 WOODLANDS ROAD
NaN
MIDDLESBROUGH
CLEVELAND
NaN
TS1 3BE
...
01642 247982
NaN
NaN
NaN
0
NaN
00M
NaN
4
NaN
3
A81005
SPRINGWOOD SURGERY
Y54
Q74
SPRINGWOOD SURGERY
RECTORY LANE
GUISBOROUGH
NaN
NaN
TS14 7DJ
...
01287 619611
NaN
NaN
NaN
0
NaN
00M
NaN
4
NaN
4
A81006
TENNANT STREET MEDICAL PRACTICE
Y54
Q74
TENNANT ST MEDICAL CENTRE
TENNANT STREET
STOCKTON-ON-TEES
CLEVELAND
NaN
TS18 2AT
...
01642 613331
NaN
NaN
NaN
1
NaN
00K
NaN
4
NaN
5 rows × 27 columns
In [7]:
cols = [0,1,9,25,14]
practices = practices.iloc[:,cols]
practices.columns = ['PRACTICE', 'NAME', 'POSTCODE', 'Prescribing Setting', 'CCG']
In [8]:
practices.head()
Out[8]:
PRACTICE
NAME
POSTCODE
Prescribing Setting
CCG
0
A81002
QUEENS PARK MEDICAL CENTRE
TS18 2AW
4
00K
1
A81003
VICTORIA MEDICAL PRACTICE
TS26 8DB
4
00K
2
A81004
WOODLANDS ROAD SURGERY
TS1 3BE
4
00M
3
A81005
SPRINGWOOD SURGERY
TS14 7DJ
4
00M
4
A81006
TENNANT STREET MEDICAL PRACTICE
TS18 2AT
4
00K
In [9]:
bnfcodes = pd.read_csv('../refdata/bnf_codes.csv')
/home/drcjar/.virtualenvs/hscic/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2717: DtypeWarning: Columns (9,11,13) have mixed types. Specify dtype option on import or set low_memory=False.
interactivity=interactivity, compiler=compiler, result=result)
In [10]:
bnfcodes.head()
Out[10]:
BNF Chapter
BNF Chapter Code
BNF Section
BNF Section Code
BNF Paragraph
BNF Paragraph Code
BNF Subparagraph
BNF Subparagraph Code
BNF Chemical Substance
BNF Chemical Substance Code
BNF Product
BNF Product Code
BNF Presentation
BNF Presentation Code
0
Gastro-Intestinal System
1
Dyspep&Gastro-Oesophageal Reflux Disease
101
Antacids and Simeticone
10101
Antacids and Simeticone
101010
Alexitol Sodium
0101010A0
Alexitol Sod
0101010A0AA
Alexitol Sod_Tab 360mg
0101010A0AAAAAA
1
Gastro-Intestinal System
1
Dyspep&Gastro-Oesophageal Reflux Disease
101
Antacids and Simeticone
10101
Antacids and Simeticone
101010
Alexitol Sodium
0101010A0
Alexitol Sod
0101010A0AA
Alexitol Sod_Tab 360mg @gn
0101010A0AAABAB
2
Gastro-Intestinal System
1
Dyspep&Gastro-Oesophageal Reflux Disease
101
Antacids and Simeticone
10101
Antacids and Simeticone
101010
Alexitol Sodium
0101010A0
Actal
0101010A0BB
Actal_Tab 360mg
0101010A0BBAAAA
3
Gastro-Intestinal System
1
Dyspep&Gastro-Oesophageal Reflux Disease
101
Antacids and Simeticone
10101
Antacids and Simeticone
101010
Almasilate
0101010B0
Almasilate
0101010B0AA
Almasilate_Susp 500mg/5ml
0101010B0AAAAAA
4
Gastro-Intestinal System
1
Dyspep&Gastro-Oesophageal Reflux Disease
101
Antacids and Simeticone
10101
Antacids and Simeticone
101010
Almasilate
0101010B0
Malinal
0101010B0BB
Malinal_Susp 500mg/5ml
0101010B0BBAAAA
In [11]:
bnfcodes.rename(columns={'BNF Presentation Code':'BNF CODE'}, inplace=True)
In [12]:
df1 = pd.merge(df, practices, on='PRACTICE')
In [13]:
df2 = pd.merge(df1, bnfcodes, on='BNF CODE')
In [14]:
df2.columns
Out[14]:
Index([u' SHA', u'PCT', u'PRACTICE', u'BNF CODE',
u'BNF NAME ', u'ITEMS ',
u'NIC ', u'ACT COST ', u'QUANTITY', u'PERIOD',
u' ', u'NAME', u'POSTCODE', u'Prescribing Setting',
u'CCG', u'BNF Chapter', u'BNF Chapter Code', u'BNF Section',
u'BNF Section Code', u'BNF Paragraph', u'BNF Paragraph Code',
u'BNF Subparagraph', u'BNF Subparagraph Code',
u'BNF Chemical Substance', u'BNF Chemical Substance Code',
u'BNF Product', u'BNF Product Code', u'BNF Presentation'],
dtype='object')
In [15]:
df2.columns = [x.strip() for x in df2.columns]
In [16]:
df2.columns
Out[16]:
Index([u'SHA', u'PCT', u'PRACTICE', u'BNF CODE', u'BNF NAME', u'ITEMS', u'NIC',
u'ACT COST', u'QUANTITY', u'PERIOD', u'', u'NAME', u'POSTCODE',
u'Prescribing Setting', u'CCG', u'BNF Chapter', u'BNF Chapter Code',
u'BNF Section', u'BNF Section Code', u'BNF Paragraph',
u'BNF Paragraph Code', u'BNF Subparagraph', u'BNF Subparagraph Code',
u'BNF Chemical Substance', u'BNF Chemical Substance Code',
u'BNF Product', u'BNF Product Code', u'BNF Presentation'],
dtype='object')
In [17]:
df2.head()
Out[17]:
SHA
PCT
PRACTICE
BNF CODE
BNF NAME
ITEMS
NIC
ACT COST
QUANTITY
PERIOD
...
BNF Section Code
BNF Paragraph
BNF Paragraph Code
BNF Subparagraph
BNF Subparagraph Code
BNF Chemical Substance
BNF Chemical Substance Code
BNF Product
BNF Product Code
BNF Presentation
0
Q44
RJN
Y05218
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
1
1.61
1.60
56
201608
...
304
Antihistamines
30401
Antihistamines
304010
Cetirizine Hydrochloride
0304010I0
Cetirizine HCl
0304010I0AA
Cetirizine HCl_Tab 10mg
1
Q44
RXA
Y00327
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
1
0.86
0.81
30
201608
...
304
Antihistamines
30401
Antihistamines
304010
Cetirizine Hydrochloride
0304010I0
Cetirizine HCl
0304010I0AA
Cetirizine HCl_Tab 10mg
2
Q44
RXA
Y03058
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
1
0.43
0.51
15
201608
...
304
Antihistamines
30401
Antihistamines
304010
Cetirizine Hydrochloride
0304010I0
Cetirizine HCl
0304010I0AA
Cetirizine HCl_Tab 10mg
3
Q44
RY7
N85638
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
9
5.70
5.79
199
201608
...
304
Antihistamines
30401
Antihistamines
304010
Cetirizine Hydrochloride
0304010I0
Cetirizine HCl
0304010I0AA
Cetirizine HCl_Tab 10mg
4
Q44
RY7
N85639
0304010I0AAAAAA
Cetirizine HCl_Tab 10mg
1
0.20
0.30
7
201608
...
304
Antihistamines
30401
Antihistamines
304010
Cetirizine Hydrochloride
0304010I0
Cetirizine HCl
0304010I0AA
Cetirizine HCl_Tab 10mg
5 rows × 28 columns
In [91]:
#lets look at beta 2 agonists
In [93]:
df2.PRACTICE.nunique()
Out[93]:
9756
In [30]:
subparas = df2['BNF Subparagraph'].unique()
In [33]:
subparas.sort()
In [34]:
subparas
Out[34]:
array(['Acids', 'Adsorbents And Bulk-Forming Drugs', 'Alcohol Dependence',
'Alcohol, Wines & Spirits', 'Alcohols & Saline', 'Alkylating Drugs',
'Allergen Immunotherapy', 'Allergic Emergencies',
'Alpha-Adrenoceptor Blocking Drugs',
'Amino Acids & Nutritional Agents', 'Aminoglycosides',
'Aminosalicylates', 'Anabolic Steroids',
'Angiotensin-Converting Enzyme Inhibitors',
'Angiotensin-II Receptor Antagonists', 'Antacids and Simeticone',
'Anti-lymphocyte Monoclonal Antibodies',
"Antibac'ial Preps Also Used Systemically",
'Antibacterial Preps Only Used Topically', 'Antibacterials',
'Antifibrinolytic Drugs & Haemostatics', 'Antifungal Preparations',
'Antigiardial Drugs', 'Antihistamines', 'Antileprotic Drugs',
'Antimalarials', 'Antimetabolites', 'Antimotility Drugs',
'Antimuscarinic Bronchodilators', 'Antimuscarinic Drugs',
"Antimuscarinic Drugs Used In Parkin'ism", 'Antiperspirants',
'Antiplatelet Drugs', 'Antiproliferative Immunosuppressants',
'Antipseudomonal Penicillins', 'Antipsychotic Depot Injections',
'Antipsychotic Drugs', 'Antispasmod.&Other Drgs Alt.Gut Motility',
'Antithyroid Drugs', 'Antituberculosis Drugs',
'Antiviral Preparations', 'Antivirals', 'Anxiolytics',
'Aromatic Inhalations', 'Ascaricides', 'Barbiturates',
'Barrier Preparations', 'Base/Dil/Susp Agents/Stabilisers',
'Benzodiazepines', 'Benzylpenicillin&Phenoxymethylpenicillin',
'Beta-Adrenoceptor Blocking Drugs', 'Betacarotene', 'Biguanides',
'Bisphosphonates and Other Drugs', 'Bitters And Tonics',
'Bladder Instillations/Urological Surgery',
'Bowel Cleansing Preparations', 'Breast Cancer',
'Broad-Spectrum Penicillins',
'Bromocriptine & Other Dopaminergic Drugs',
'Bulk-Forming Laxatives', 'CNS Stimulants and drugs used for ADHD',
'Calcitonin and Parathyroid Hormone', 'Calcium Supplements',
'Calcium-Channel Blockers', 'Camouflagers', 'Carbapenems',
'Cardiac Glycosides', 'Cardiopulmonary Resuscitation',
'Cationic Surfactants & Soaps',
'Centrally-Acting Antihypertensive Drugs', 'Cephalosporins',
'Chelates And Complexes', 'Chlorhexidine Salts',
'Chlorine & Iodine', 'Chromium', 'Chronic Hepatitis B',
'Chronic Hepatitis C', 'Clindamycin and Lincomycin',
"Co Haemorrhoidal Prep's + Corticosteroid",
'Colouring,Flavouring & Sweetening Agents',
'Combined Hormonal Contraceptives', 'Combined Hormonal Systems',
'Compound Alginates&Prop Indigestion Prep',
'Compound Bronchodilator Preparations',
'Compound Vit/Mineral Formulations', 'Concentrated Waters',
'Control Of Epilepsy', 'Cordials/Soft Drinks',
"Cortico'oids & Other Immunosuppressants", 'Corticosteroids',
'Corticosteroids (Respiratory)', 'Cough Suppressants',
'Cromoglycate and Related Therapy', 'Cytomegalovirus Infection',
'Desloughing Agents', "Dgs Which Enhance Neuromus'ar Transmi'on",
'Diabetic Diagnostic & Monitoring Agents', 'Digestive Aids',
'Disease-Specific Immunoglobulins',
'Disinfectants,Preserv&Sterilising Agents',
'Diuretics With Potassium',
'Dopaminergic Drugs Used In Parkinsonism',
'Drugs Affecting Biliary Composition&Flow',
'Drugs Affecting The Immune Response', 'Drugs For Arrhythmias',
'Drugs For Erectile Dysfunction',
'Drugs For Oral Ulceration & Inflammation',
'Drugs For Pneumocystis Pneumonia',
'Drugs For Premature Ejaculation', 'Drugs For Tapeworm Infections',
'Drugs For Threadworms', 'Drugs For Urinary Retention',
'Drugs Used In Nasal Allergy', 'Drugs Used In Nausea And Vertigo',
'Drugs Used In Status Epilepticus', 'Drugs Used In Urological Pain',
'Drugs Used for Mania and Hypomania',
'Drugs Used in Metabolic Disorders',
'Drugs affecting Gonadotrophins',
'Drugs for Cytotoxic-Induced side-effects', 'Drugs for Dementia',
'Drugs used in Megaloblastic Anaemias', 'Drugs used in Neutropenia',
'Drugs used in Platelet Disorders',
"Drugs/Urin'y Frequ'cy Enuresis & Incont", 'Dusting-Powders',
'Echinocandin Antifungals', 'Electrolytes and Water',
'Emergency Contraception', 'Emollient Bath & Shower Preparations',
'Emollients', 'Enkephalinase Inhibitors', 'Enteral Nutrition',
'Enzymes', 'Essentialtremor,Chorea,Tics&Reldisorders',
"Expectorant & Demulcent Cough Prep's", 'Faecal Softeners',
'Filaricides', 'Fluoride', 'Food Allergy', 'Foods',
'Foods For Special Diets', 'Gastro-Intestinal Anti-Obesity Drugs',
'Glandular', 'Gout & Cytotoxic Induced Hyperiuicaemia',
'H2-Receptor Antagonists', 'HIV Infection',
'Herpes Simplex and Varicella-Zoster', 'Homeopathic Preparations',
'Household & Other Over The Counter Lines', 'Hypercalcaemia',
'Hypnotics', 'Hypoplastic/Haemolytic & Renal Anaemias',
'Hypothalamic&Ant Pituit Hormone&Antioest',
'IUD Progestogen-only Device', 'Imidazole Antifungals',
'Individ Formulated Preps-Prepared Extemp',
'Individually Formulated Preps-Bought In', 'Influenza',
'Inhalational Anaesthetics', 'Inotropic Sympathomimetics',
'Intermediate And Long-Acting Insulins', 'Intravenous Anaesthetics',
'Intravenous Nutrition', 'Leishmaniacides',
'Leukotriene Receptor Antagonists', 'Lipid-Regulating Drugs',
'Local Anaesthetics', 'Local Care of Stoma',
'Local Corticosteroid Injections', 'Loop Diuretics',
'Lozenges & Sprays', 'Macrolides', 'Magnesium',
'Male Sex Hormones And Antagonists', 'Management of Anal Fissures',
'Mecillinams', 'Medicated Stockings',
'Metronidazole, Tinidazole & Ornidazole', 'Metyrapone',
'Miscellaneous Topical Preparations',
'Monoamine-Oxidase Inhibitors (Maois)',
'Mouth-Washes, Gargles, And Dentifrices', 'Mucolytics',
'Multivitamin Preparations', 'Mydriatics And Cycloplegics',
'Nasal Prepn for Infection', 'Nicotinamide (B7)',
'Nicotine Dependence', 'Nitrates', 'Non-Opioid Analgesics',
'Non-Opioid Analgesics And Compound Prep',
'Non-Steroidal Anti-Inflammatory Drugs', 'Normal Immunoglobulin',
'Ocular Diagnos/Peri-op Prepn&Photodyn Tt', 'Oestrogens',
'Oestrogens And Hrt', 'Oils', 'Opioid Analgesics',
'Opioid Dependence', 'Oral Anticoagulants', 'Oral Bicarbonate',
'Oral Iron', 'Oral Potassium', 'Oral Preparations For Acne',
'Oral Progestogen-only Contraceptives', 'Oral Sodium And Water',
'Oropharyngeal Anti-Infective Drugs', 'Osmotic Diuretics',
'Osmotic Laxatives', 'Other Adrenergic Neurone Blocking Drugs',
'Other Andrenoceptor Agonists',
'Other Anti-Inflammatory Preparations', 'Other Antianginal Drugs',
'Other Antidepressant Drugs', 'Other Antidiabetic Drugs',
'Other Antifungals', 'Other Antineoplastic Drugs',
'Other Beta-Lactam Antibiotics',
'Other Drugs For Rheumatic Diseases',
'Other Drugs Used In Constipation', 'Other Eye Preparations',
'Other Gases', 'Other Health Supplements',
'Other Immunomodulating Drugs', 'Other Mineral Formulations',
'Other Preparations', 'Other Vitamin B Preparations',
'Otitis Externa', 'Otitis Media', 'Oxidisers & Dyes', 'Pancreatin',
'Parasiticidal Preparations', 'Parenteral Anticoagulants',
'Parenteral Iron', 'Parenteral Progestogen-only Contracep',
'Penicillinase-Resistant Penicillins',
'Peripheral Opioid-Receptor Antagonists',
'Peripheral Vasodilators & Related Drugs', 'Phenolics',
'Phosphate Binding Agents', 'Phosphate Supplements',
'Phosphodiesterase Type-4 Inhibitors', 'Poisoning Antidotes',
'Polyene Antifungals', 'Posterior Pituitary Hormones&Antagonists',
'Pot-Sparing Diuretics&Aldosterone Antag',
'Potassium Sparing Diuretics & Compounds',
"Prep's For Minor Cuts & Abrasions", 'Preparations For Eczema',
'Preparations For Psoriasis',
'Preparations For Vaginal/Vulval Changes',
'Preparations For Warts And Calluses', 'Progestogens',
'Progestogens & Progesterone Receptor Mod',
'Prophylaxis Of Migraine', 'Prostaglandin Analogues',
'Prostate Cancer & Gonadorelin Analogues', 'Proton Pump Inhibitors',
'Purified Water', 'Pyridoxine Hydrochloride (B6)', 'Quinolones',
'Rectal Sclerosants', 'Removal of Ear Wax & other Substances',
'Renin Inhibitors', 'Replacement Therapy',
'Respiratory Syncytial Virus',
'Rheumatic Disease Suppressant Drugs', 'Riboflavine (B2)',
'Rubefacients,Top NSAIDS,Capsaicin & Poul', 'Schistosomicides',
'Selective Antimuscarinics', 'Selective Beta(2)-Agonists',
'Selective Serotonin Re-Uptake Inhibitors', 'Selenium',
"Shampoos And Some Other Scalp Prep's", 'Short-Acting Insulins',
'Single Substances', 'Skeletal Muscle Relaxants',
'Sodium Bicarbonate', 'Somatostatin Analogues',
'Some Other Antibiotics', 'Soothing Haemorrhoidal Preparations',
'Spermicidal Contraceptives', 'Sterile Water',
'Stimulant Laxatives', 'Sulfonamides And Trimethoprim',
'Sulfonylureas', 'Sunscreening Preparations',
'Systemic Nasal Decongestants',
'Tear Deficiency,Eye Lubricant/Astringent',
'Test for Helicobacter Pylori', 'Tetracyclines', 'Theophylline',
'Thiamine Hydrochloride (B1)', 'Thiazides And Related Diuretics',
'Thyroid Hormones', 'Tinctures', 'Toiletries',
'Top Local Anaesthetics & Antipruritics',
'Topical Circulatory Preparations', 'Topical Corticosteroids',
'Topical Nasal Decongestants', 'Topical Preparation For Rosacea',
'Topical Preparations For Acne', 'Treatment Of Acute Migraine',
'Treatment Of Dry Mouth', 'Treatment Of Glaucoma',
'Treatment Of Hypoglycaemia', 'Triazole Antifungals',
'Tricyclic & Related Antidepressant Drugs',
'Urinary-Tract Infections', 'Use of Corticosteroids',
'Vaccines And Antisera', 'Vaginal and Vulval Infections',
'Vasoconstrictor Sympathomimetics',
'Vasodilator Antihypertensive Drugs',
'Vehicles & Emulsifying Agents', 'Vitamin A', 'Vitamin B Compound',
'Vitamin C & Bioflavonoids', 'Vitamin C (Ascorbic Acid)',
'Vitamin D', 'Vitamin E', 'Vitamin K', 'X-Ray Contrast Media',
'Zinc'], dtype=object)
In [37]:
df2[df2['BNF Subparagraph'] == "Selective Beta(2)-Agonists"]['BNF Chemical Substance'].unique()
Out[37]:
array(['Salbutamol', 'Salmeterol', 'Terbutaline Sulphate',
'Formoterol Fumarate', 'Indacaterol/Glycopyrronium',
'Indacaterol Maleate', 'Olodaterol', 'Bambuterol Hydrochloride'], dtype=object)
In [43]:
df2[df2['BNF Subparagraph'] == "Selective Beta(2)-Agonists"].groupby('BNF Chemical Substance').ITEMS.sum()
Out[43]:
BNF Chemical Substance
Bambuterol Hydrochloride 435
Formoterol Fumarate 13773
Indacaterol Maleate 3384
Indacaterol/Glycopyrronium 4697
Olodaterol 129
Salbutamol 1742308
Salmeterol 51065
Terbutaline Sulphate 52748
Name: ITEMS, dtype: int64
In [49]:
df3 = df2[df2['BNF Subparagraph'] == "Selective Beta(2)-Agonists"].groupby(['PRACTICE', 'BNF Chemical Substance']).ITEMS.sum()
In [63]:
df4 = df3.unstack()
In [64]:
df4.head()
Out[64]:
BNF Chemical Substance
Bambuterol Hydrochloride
Formoterol Fumarate
Indacaterol Maleate
Indacaterol/Glycopyrronium
Olodaterol
Salbutamol
Salmeterol
Terbutaline Sulphate
PRACTICE
A81002
NaN
1.0
1.0
1.0
NaN
844.0
22.0
42.0
A81003
NaN
NaN
NaN
NaN
NaN
303.0
6.0
12.0
A81004
NaN
2.0
NaN
8.0
NaN
298.0
2.0
24.0
A81005
NaN
4.0
NaN
1.0
NaN
327.0
23.0
4.0
A81006
NaN
NaN
NaN
NaN
NaN
564.0
22.0
23.0
In [65]:
df4.describe()
Out[65]:
BNF Chemical Substance
Bambuterol Hydrochloride
Formoterol Fumarate
Indacaterol Maleate
Indacaterol/Glycopyrronium
Olodaterol
Salbutamol
Salmeterol
Terbutaline Sulphate
count
232.000000
4046.000000
1462.000000
1701.000000
101.000000
8246.000000
6404.000000
6794.000000
mean
1.875000
3.404103
2.314637
2.761317
1.277228
211.291293
7.973923
7.763909
std
1.955539
4.688684
2.608792
3.293228
0.601977
166.309600
9.619276
9.131756
min
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
25%
1.000000
1.000000
1.000000
1.000000
1.000000
97.000000
2.000000
2.000000
50%
1.000000
2.000000
1.000000
2.000000
1.000000
176.000000
5.000000
5.000000
75%
2.000000
4.000000
3.000000
3.000000
1.000000
289.000000
10.000000
10.000000
max
16.000000
77.000000
26.000000
41.000000
4.000000
2348.000000
145.000000
141.000000
In [68]:
df4 = df4.fillna(0)
In [69]:
df4.head()
Out[69]:
BNF Chemical Substance
Bambuterol Hydrochloride
Formoterol Fumarate
Indacaterol Maleate
Indacaterol/Glycopyrronium
Olodaterol
Salbutamol
Salmeterol
Terbutaline Sulphate
PRACTICE
A81002
0.0
1.0
1.0
1.0
0.0
844.0
22.0
42.0
A81003
0.0
0.0
0.0
0.0
0.0
303.0
6.0
12.0
A81004
0.0
2.0
0.0
8.0
0.0
298.0
2.0
24.0
A81005
0.0
4.0
0.0
1.0
0.0
327.0
23.0
4.0
A81006
0.0
0.0
0.0
0.0
0.0
564.0
22.0
23.0
In [71]:
df4.max()
Out[71]:
BNF Chemical Substance
Bambuterol Hydrochloride 16.0
Formoterol Fumarate 77.0
Indacaterol Maleate 26.0
Indacaterol/Glycopyrronium 41.0
Olodaterol 4.0
Salbutamol 2348.0
Salmeterol 145.0
Terbutaline Sulphate 141.0
dtype: float64
In [114]:
df4.sort(columns=['Olodaterol'], ascending=False).head(4)
/home/drcjar/.virtualenvs/hscic/lib/python2.7/site-packages/ipykernel/__main__.py:1: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
if __name__ == '__main__':
Out[114]:
BNF Chemical Substance
Bambuterol Hydrochloride
Formoterol Fumarate
Indacaterol Maleate
Indacaterol/Glycopyrronium
Olodaterol
Salbutamol
Salmeterol
Terbutaline Sulphate
PRACTICE
J81011
0.0
2.0
7.0
7.0
4.0
262.0
13.0
6.0
L84048
0.0
4.0
2.0
0.0
3.0
237.0
2.0
1.0
L84606
0.0
4.0
0.0
0.0
3.0
162.0
3.0
4.0
B81025
0.0
8.0
3.0
3.0
3.0
830.0
9.0
24.0
In [113]:
df2[df2['PRACTICE'] == 'J81011']['NAME'].head(1)
Out[113]:
7908 WAREHAM SURGERY
Name: NAME, dtype: object
In [ ]:
Content source: drcjar/prescribing-seminar-dec2016
Similar notebooks: