Are statin prescribing ratios different for dispensing practices?

1. Obtain GP Prescribing data

2. Cut GP Prescribing data for things of interest (e.g statins)

3. Obtain list of dispensing practices

3a. Add codes to list of dispensing practices (name and address only is provided)

4. Combine things of interest cut and dispensing practice list

5. Compare dispensing vs non-dispensing prescribing ratios for things of interest


In [1]:
import requests
from StringIO import StringIO
from numpy import nan as NA
import pandas as pd
import zipfile
import re
%matplotlib inline
import matplotlib.pyplot as plt
import xlrd
import statsmodels.api as sm
from patsy import dmatrices, dmatrix
import scipy as scipy
import numpy as np

In [2]:
def fetch_prescribing_data():
    url = 'http://datagov.ic.nhs.uk/presentation/2015_01_January/T201501PDPI+BNFT.CSV' #gp prescribing data (Jan 2015)
    r = requests.get(url)
    data = r.content
    df = (pd.read_csv(StringIO(data)))
    df.to_csv('datas/T201501PDPI+BNFT.CSV')

def fetch_dispensary_data():
    url = 'http://systems.hscic.gov.uk/data/ods/datadownloads/data-files/edispensary.zip'
    r = requests.get(url)
    z = zipfile.ZipFile(StringIO(r.content))
    df = pd.read_csv(z.open('edispensary.csv'))
    df.to_csv('datas/edispensary.csv')

def fetch_gp_details():
    url = 'http://systems.hscic.gov.uk/data/ods/datadownloads/data-files/epraccur.zip'
    r = requests.get(url)
    z = zipfile.ZipFile(StringIO(r.content))
    df = pd.read_csv(z.open('epraccur.csv'))
    df.to_csv('datas/epraccur.csv')

def clean_prescribing_data(df):
    df.columns = [x.strip() for x in df.columns] #gets rid of variable whitespace
    return(df)

def cut_prescribing_data(df, cut_pattern, junk):
    df = df[df['BNF NAME'].str.contains(cut_pattern)] #cut for rows with target in them
    df = df[~df['BNF NAME'].str.contains(junk)] #throw away unwanted drugs
    #df.to_csv('datas/%sJan2015.csv' % target) #save the result
    return(df)

def drugs_analysis(df):
    print 'Unique drugs in the analysis: '
    print df['BNF NAME'].unique() 
    print '\n'
    print 'Number of practices prescribing each drug in the analysis: '
    print df['BNF NAME'].value_counts()
    print '\n'

    
def clean_dispensing_practice_addresses(dpad):
    dpad = dpad['Dispensing Practices Address Details'].dropna()
    dpad = dpad.reset_index()
    del dpad['index']
    dpad['Dispensing Practices Address Details'] = dpad['Dispensing Practices Address Details'].str.strip()
    dpad['Dispensing Practices Address Details'] = dpad['Dispensing Practices Address Details'].str.replace('\n', ' ')
    dpad['NAME'] = dpad['Dispensing Practices Address Details'].str.split(',').str[0].str.upper()
    dpad['POSTCODE'] = dpad['Dispensing Practices Address Details'].str.split(',').str[-1].astype(str).str.strip()
    dpad.ix[254,2] = 'BN25 1HH' #one practice lacked a postcode.... we fix this manually
    dpad.ix[254,1] = 'Old School Surgery'
    return(dpad)

def validate_dispensing_postcodes():
    assert(len(dpad[~dpad.Postcode.str.contains(r'[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][A-Z]{2}')]) == 0) #length of dataframe of postcodes that don't pass regex should be 0 

def add_dispensing_practice_column(df):
    df['DP'] = df.PRACTICE.isin(dpad.PRACTICE) #add column DP to identify Dispensing Practices
    return(df)

def add_proportion_bad(df, bad):
    df['is_bad'] = df['BNF NAME'].str.contains(bad) #add column for Is Bad
    df = df.groupby(['DP','PRACTICE', 'is_bad']).ITEMS.sum()
    df = df.unstack()
    df = df.reset_index()
    df = df.fillna(0.0) #applying groupby when there are no items in a category generates NaNs where we would instead prefer 0's
    df.columns = ['DP', 'PRACTICE', 'good', 'bad']
    df['Proportion'] = (df['bad'] / (df['bad'] + df['good']))
    return(df)

def add_gp_details(df):
    df = pd.merge(df, gpdetail, on='PRACTICE')
    return(df)


def prescribing_setting_analysis(df):
    lookup =  {0:'Other' , 1:'WIC Practice' , 2:'OOH Practice' , 3:'WIC + OOH Practice' , 4:'GP Practice' , 
               8:'Public Health Service' , 9:'Community Health Service' , 10:'Hospital Service' , 11:'Optometry Service' , 
              12:'Urgent & Emergency Care' , 13:'Hospice' , 14:'Care Home / Nursing Home' , 15:'Border Force' , 
              16:'Young Offender Institution' , 17:'Secure Training Centre' , 18:'Secure Children\'s Home' , 19:'Immigration Removal Centre' , 
              20:'Court' , 21:'Police Custody' , 22:'Sexual Assault Referral Centre\'(SARC)' , 24:'Other – Justice Estate' , 
              25:'Prison'}  
   
    df['Prescribing Setting'] = df['Prescribing Setting'].map(lambda x: lookup.get(x))
    
    print 'Unique prescribing settings: '
    print df['Prescribing Setting'].unique() 
    print '\n'

    
    print 'Number of each practices in each type of prescribing setting: '
    print df['Prescribing Setting'].value_counts()
    print '\n'

    
    print 'Mean badness proportion by prescribing setting: '
    prop_mean = df.groupby('Prescribing Setting').Proportion.mean()
    prop_mean.sort(ascending=False)
    print prop_mean
    

def throw_away_not_gp_practices(df):
    df = df[df['Prescribing Setting'] == 'GP Practice'] #throw away ones that aren't GP practices
    return(df)

def mwwranksum_and_z_stat(df):
    from scipy import stats

    z_stat, p_val = stats.ranksums(df[df.DP == True]['Proportion'], df[df.DP == False]['Proportion'])

    print "MWW RankSum P for treatments 1 and 2 =", p_val
    print "Z statistic for treatments 1 and 2 =", z_stat
    
def model(df):
           
    y, X = dmatrices('Proportion ~ C(DP)', data=df, return_type='dataframe') 

    mod = sm.Poisson(y, X) #http://statsmodels.sourceforge.net/devel/endog_exog.html
    
    res = mod.fit(maxiter=100)
    
    print res.summary()
    print '\nIRR\n',np.exp(res.params)[:2] 

    return res

def proportion_analysis(df, target):
    df.columns = ['DP', 'PRACTICE', 'not_%s' % target[:8], target[:8], 'Proportion', 'NAME', 'POSTCODE', 
                  'Prescribing Setting', 'CCG']
    
    print '\n non-dispensing practices \n'
    df[df['DP'] == False].hist(bins=40)
    print df[df['DP'] == False].describe()
    print ('\nmean proportion is: %.3f \nmedian proportion is: %.3f \nvariance is: %.3f \nskew is: %3.f\n' % 
            (df[df['DP'] == False]['Proportion'].mean(),  df[df['DP'] == False]['Proportion'].median(),  
             df[df['DP'] == False]['Proportion'].var(),  
             df[df['DP'] == False]['Proportion'].skew()))
    
    print '\n dispensing practices: \n'
    df[df['DP'] == True].hist(bins=28)
    print df[df['DP'] == True].describe()
    print ('\nmean proportion is: %.3f \nmedian proportion is: %.3f \nvariance is: %.3f \nskew is: %3.f\n' % 
            (df[df['DP'] == True]['Proportion'].mean(),  df[df['DP'] == True]['Proportion'].median(),  
             df[df['DP'] == True]['Proportion'].var(),  
             df[df['DP'] == True]['Proportion'].skew()))
    
    
    df[['DP', 'Proportion']].boxplot(by='DP', figsize=(6,6))
    plt.title("Prescribing in non-dispensing vs dispensing practices")
    plt.suptitle("")
    plt.ylabel('Proportion of group items that are %s' % target[:8])
    plt.xlabel('Dispensing practice')
    
    mwwranksum_and_z_stat(df)
        
    model(df)
    
    
def prep_data_for_stata(df):
    
    ccg_codes = df.CCG.unique()
    ccg_lookup = zip(list(ccg_codes), range(0,209))
    ccg_lookup = dict(ccg_lookup)
    
    df = df[['DP', 'Proportion', 'CCG']]
    df['DP'] = df['DP'].astype(str).str.replace('False','0').str.replace('True','1')
    df['CCG'] = df['CCG'].map(lambda x: ccg_lookup.get(x))
    df['DP'] = df['DP'].astype(int)
    df['CCG'] = df['CCG'].astype(int)
    
    df.to_csv('pa_research_for_stata.csv')
    
    
def pa_research(df, cut_pattern, junk, target):
    df = cut_prescribing_data(df, cut_pattern, junk)
    drugs_analysis(df)
    df = add_dispensing_practice_column(df)
    df = add_proportion_bad(df, target)
    df = add_gp_details(df)
    prescribing_setting_analysis(df)
    df = throw_away_not_gp_practices(df)
    proportion_analysis(df, target)

#nb df = pd.read_csv('http://datagov.ic.nhs.uk/presentation/2015_01_January/T201501PDPI+BNFT.CSV') should also work but seems slower

In [3]:
gpdetail = pd.read_csv('datas/epraccur.csv') #from http://systems.hscic.gov.uk/data/ods/datadownloads/data-files/epraccur.zip

dpad_formatting_junk = ['Dispensing Practices Address Details', 'Primary Care Trust:', 'Report For:', 'Practice Name and Address', 'January 2015']
dpad = pd.read_excel('datas/Disp Pracs Name and Address 2015-01-31.xls', usecols=[0], na_values=dpad_formatting_junk) #load dispensing practice list

dpad = clean_dispensing_practice_addresses(dpad)

gpdetail = gpdetail.icol([1,2,10,26,15]) #throw away columns we don't care about
gpdetail.columns = ['PRACTICE', 'NAME', 'POSTCODE', 'Prescribing Setting', 'CCG']

dpad = pd.merge(gpdetail, dpad, on=['NAME','POSTCODE']) #merge to add practice codes

df = pd.read_csv('datas/T201501PDPI+BNFT.CSV') #commented because need only run once and is slow
df = clean_prescribing_data(df) #commented because need only run once and is slow

In [4]:
def statin_analysis(df):
    print '\n---Statin analysis---\n'
    cut_pattern = 'statin|Rosuvastatin|Lipitor|Lescol|Lipostat|Crestor|Zocor'
    junk = 'Nystatin|Sandostatin|Ecostatin'
    target = 'Rosuvastatin|Lipitor|Lescol|Lipostat|Crestor|Zocor'
    
    pa_research(df, cut_pattern, junk, target)

In [5]:
def ppi_analysis(df):
    print '\n---PPI analysis---\n'
    cut_pattern = 'prazole|Esomeprazole|Rabeprazole|Nexium|Losec|Zoton|Protium|Pariet'
    junk = 'Aripiprazole'
    target = 'Esomeprazole|Rabeprazole|Nexium|Losec|Zoton|Protium|Pariet'
    
    pa_research(df, cut_pattern, junk, target)

In [6]:
def ace_analysis(df):
    print '\n---ACE-i analysis---\n'
    cut_pattern = 'pril|Captopril|Capoten|Noyada|Innovace|Fosinopril|Tanatril|Imidapril|Zestril|Perdix|Moexipril|Coversyl|Quinapril|Quinil|Accupro|Tritace|Trandolapril|Cilazapril'
    junk = 'Caprilon|Sprilon'
    target = 'Captopril|Capoten|Noyada|Innovace|Fosinopril|Tanatril|Imidapril|Zestril|Perdix|Moexipril|Coversyl|Quinapril|Quinil|Accupro|Tritace|Trandolapril|Cilazapril'
    
    pa_research(df, cut_pattern, junk, target)

In [7]:
def arb_analysis(df):
    print '\n---ARB-II analysis---\n'
    cut_pattern = 'sartan|Azilsartan|Edarbi|Amias|Eprosartan|Teveten|Aprovel|Cozaar|Olmesartan|Olmetec|Micardis|Telmisartan|Valsartan|Diovan'
    junk = 'no_junk_found'
    target = 'Azilsartan|Edarbi|Amias|Eprosartan|Teveten|Aprovel|Cozaar|Olmesartan|Olmetec|Micardis|Telmisartan|Valsartan|Diovan'
    
    pa_research(df, cut_pattern, junk, target)

In [8]:
def main():
    #statin_analysis(df)
    ppi_analysis(df)
    #ace_analysis(df)
    #arb_analysis(df)

need to fix add_proportion using this: http://stackoverflow.com/questions/23377108/pandas-percentage-of-total-with-groupby

note limitation currently is that have not made combined preparations a target or excluded as junk... they will currently still be included

incorporate tom hunger feedback

?pep8

more unit testing

functions should have docstring


In [11]:
main()


---Statin analysis---

Unique drugs in the analysis: 
['Simvastatin_Tab 20mg                    '
 'Simvastatin_Tab 40mg                    '
 'Atorvastatin_Tab 40mg                   '
 'Rosuvastatin Calc_Tab 10mg              '
 'Rosuvastatin Calc_Tab 20mg              '
 'Rosuvastatin Calc_Tab 5mg               '
 'Simvastatin/Ezetimibe_Tab 80mg/10mg     '
 'Atorvastatin_Tab 10mg                   '
 'Atorvastatin_Tab 20mg                   '
 'Atorvastatin_Tab 80mg                   '
 'Lipitor_Tab 20mg                        '
 'Fluvastatin Sod_Cap 40mg                '
 'Fluvastatin Sod_Tab 80mg M/R            '
 'Pravastatin Sod_Tab 10mg                '
 'Pravastatin Sod_Tab 20mg                '
 'Pravastatin Sod_Tab 40mg                '
 'Simvastatin_Tab 10mg                    '
 'Simvastatin_Tab 80mg                    '
 'Zocor_Tab 40mg                          '
 'Rosuvastatin Calc_Tab 40mg              '
 'Crestor_Tab 10mg                        '
 'Lipitor_Tab 10mg                        '
 'Lipitor_Tab 40mg                        '
 'Lipitor_Tab 80mg                        '
 'Zocor_Tab 20mg                          '
 'Fluvastatin Sod_Cap 20mg                '
 'Atorvastatin_Tab Chble 10mg S/F         '
 'Crestor_Tab 5mg                         '
 'Lipostat_Tab 40mg                       '
 'Zocor_Tab 10mg                          '
 'Simvastatin_Oral Susp 20mg/5ml S/F      '
 'Simvastatin_Oral Susp 40mg/5ml S/F      '
 'Lipostat_Tab 20mg                       '
 'Zocor_Tab 80mg                          '
 'Simvastatin/Ezetimibe_Tab 40mg/10mg     '
 'Lescol_Cap 20mg                         '
 'Simvastatin/Ezetimibe_Tab 20mg/10mg     '
 'Lipostat_Tab 10mg                       '
 'Atorvastatin_Tab Chble 20mg S/F         '
 'Atorvastatin_Tab 30mg                   '
 'Atorvastatin_Tab 60mg                   '
 'Crestor_Tab 20mg                        '
 'Lescol XL_Tab 80mg                      '
 'Lipitor_Tab Chble 20mg                  '
 'Crestor_Tab 40mg                        '
 'Atorvastatin_Oral Soln 20mg/5ml         '
 'Atorvastatin_Liq Spec 10mg/5ml          '
 'Atorvastatin_Oral Susp 20mg/5ml         '
 'Lipitor_Tab Chble 10mg                  '
 'Lescol_Cap 40mg                         '
 'Pravastatin Sod_Liq Spec 40mg/5ml       '
 'Pravastatin Sod_Pdr Sach 5mg            '
 'Pravastatin Sod_Liq Spec 5mg/5ml        '
 'Simvastatin_Liq Spec 20mg/5ml           '
 'Atorvastatin_Liq Spec 40mg/5ml          ']


Number of practices prescribing each drug in the analysis: 
Simvastatin_Tab 40mg                        8031
Simvastatin_Tab 20mg                        7996
Atorvastatin_Tab 40mg                       7953
Atorvastatin_Tab 20mg                       7950
Atorvastatin_Tab 10mg                       7900
Atorvastatin_Tab 80mg                       7773
Simvastatin_Tab 10mg                        7576
Pravastatin Sod_Tab 40mg                    7261
Pravastatin Sod_Tab 20mg                    7162
Rosuvastatin Calc_Tab 10mg                  6815
Pravastatin Sod_Tab 10mg                    6504
Rosuvastatin Calc_Tab 5mg                   6383
Rosuvastatin Calc_Tab 20mg                  5969
Simvastatin_Tab 80mg                        5403
Rosuvastatin Calc_Tab 40mg                  3438
Fluvastatin Sod_Cap 20mg                    2342
Fluvastatin Sod_Cap 40mg                    2130
Lipitor_Tab 10mg                            2118
Lipitor_Tab 20mg                            1686
Lipitor_Tab 40mg                            1141
Fluvastatin Sod_Tab 80mg M/R                1034
Simvastatin/Ezetimibe_Tab 40mg/10mg          966
Atorvastatin_Tab 60mg                        614
Simvastatin/Ezetimibe_Tab 20mg/10mg          586
Simvastatin_Oral Susp 40mg/5ml S/F           539
Atorvastatin_Tab Chble 20mg S/F              428
Atorvastatin_Tab 30mg                        404
Atorvastatin_Tab Chble 10mg S/F              379
Crestor_Tab 10mg                             364
Lipitor_Tab 80mg                             353
Zocor_Tab 20mg                               343
Simvastatin_Oral Susp 20mg/5ml S/F           342
Zocor_Tab 40mg                               268
Simvastatin/Ezetimibe_Tab 80mg/10mg          247
Crestor_Tab 5mg                              227
Lipostat_Tab 40mg                            189
Crestor_Tab 20mg                             161
Zocor_Tab 10mg                               157
Lipostat_Tab 20mg                            104
Lescol_Cap 20mg                               75
Lescol_Cap 40mg                               64
Lipitor_Tab Chble 20mg                        63
Lescol XL_Tab 80mg                            59
Lipostat_Tab 10mg                             49
Lipitor_Tab Chble 10mg                        43
Crestor_Tab 40mg                              40
Atorvastatin_Oral Susp 20mg/5ml               36
Zocor_Tab 80mg                                24
Atorvastatin_Liq Spec 10mg/5ml                11
Atorvastatin_Oral Soln 20mg/5ml                7
Pravastatin Sod_Liq Spec 40mg/5ml              3
Atorvastatin_Liq Spec 40mg/5ml                 1
Pravastatin Sod_Pdr Sach 5mg                   1
Simvastatin_Liq Spec 20mg/5ml                  1
Pravastatin Sod_Liq Spec 5mg/5ml               1
dtype: int64


Unique prescribing settings: 
['GP Practice' 'OOH Practice' 'Public Health Service'
 'Care Home / Nursing Home' 'Community Health Service' 'Other'
 'WIC Practice' 'Hospice' 'Hospital Service' 'Urgent & Emergency Care'
 'Optometry Service' 'Prison' 'WIC + OOH Practice']


Number of each practices in each type of prescribing setting: 
GP Practice                 7865
OOH Practice                 114
Community Health Service      87
Other                         55
Care Home / Nursing Home      36
WIC Practice                  31
Public Health Service         16
Hospital Service              16
Hospice                        6
Urgent & Emergency Care        6
Prison                         3
WIC + OOH Practice             2
Optometry Service              1
dtype: int64


Mean badness proportion by prescribing setting: 
Prescribing Setting
Hospital Service            0.107639
WIC Practice                0.069798
Community Health Service    0.068537
OOH Practice                0.036434
GP Practice                 0.029918
Care Home / Nursing Home    0.018058
Other                       0.009263
Public Health Service       0.007589
WIC + OOH Practice          0.000000
Urgent & Emergency Care     0.000000
Prison                      0.000000
Optometry Service           0.000000
Hospice                     0.000000
Name: Proportion, dtype: float64

 non-dispensing practices 

          DP  not_Rosuvast     Rosuvast   Proportion
count   6851   6851.000000  6851.000000  6851.000000
mean       0    628.145088    17.823821     0.027402
std        0    436.720303    19.798785     0.026235
min    False      0.000000     0.000000     0.000000
25%        0    314.500000     5.000000     0.011494
50%        0    526.000000    12.000000     0.021632
75%        0    834.000000    24.000000     0.037055
max    False   3716.000000   252.000000     1.000000

mean proportion is: 0.027 
median proportion is: 0.022 
variance is: 0.001 
skew is:   9


 dispensing practices: 

         DP  not_Rosuvast     Rosuvast   Proportion
count  1014   1014.000000  1014.000000  1014.000000
mean      1    922.237673    43.641026     0.046914
std       0    583.815846    43.504653     0.043900
min    True      7.000000     0.000000     0.000000
25%       1    503.250000    14.000000     0.020305
50%       1    783.000000    31.000000     0.036560
75%       1   1215.250000    56.750000     0.060542
max    True   5345.000000   344.000000     0.496923

mean proportion is: 0.047 
median proportion is: 0.037 
variance is: 0.002 
skew is:   4

MWW RankSum P for treatments 1 and 2 = 1.5062214385e-72
Z statistic for treatments 1 and 2 = 18.0142449302
Optimization terminated successfully.
         Current function value: 0.118392
         Iterations 9
                          Poisson Regression Results                          
==============================================================================
Dep. Variable:             Proportion   No. Observations:                 7865
Model:                        Poisson   Df Residuals:                     7863
Method:                           MLE   Df Model:                            1
Date:                Mon, 13 Jul 2015   Pseudo R-squ.:                0.005247
Time:                        11:01:10   Log-Likelihood:                -931.15
converged:                       True   LL-Null:                       -936.06
                                        LLR p-value:                  0.001723
=================================================================================
                    coef    std err          z      P>|z|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept        -3.5971      0.073    -49.286      0.000        -3.740    -3.454
C(DP)[T.True]     0.5377      0.162      3.312      0.001         0.220     0.856
=================================================================================

IRR
Intercept        0.027402
C(DP)[T.True]    1.712037
dtype: float64

---PPI analysis---

Unique drugs in the analysis: 
['Esomeprazole_Tab E/C 40mg               '
 'Lansoprazole_Cap 30mg (E/C Gran)        '
 'Lansoprazole_Cap 15mg (E/C Gran)        '
 'Lansoprazole_Orodisper Tab 30mg         '
 'Omeprazole_Cap E/C 20mg                 '
 'Omeprazole_Tab E/C 20mg                 '
 'Omeprazole_Cap E/C 40mg                 '
 'Zoton_FasTab Tab 30mg                   '
 'Esomeprazole_Tab E/C 20mg               '
 'Nexium_Tab 20mg                         '
 'Lansoprazole_Orodisper Tab 15mg         '
 'Omeprazole_Cap E/C 10mg                 '
 'Omeprazole_Tab Disper 10mg (E/C Pellets)'
 'Omeprazole_Tab Disper 20mg (E/C Pellets)'
 'Omeprazole_Tab E/C 10mg                 '
 'Losec_Cap E/C 20mg                      '
 'Losec MUPS_Tab Disper 10mg (E/C Pellets)'
 'Pantoprazole_Tab E/C 40mg               '
 'Pantoprazole_Tab E/C 20mg               '
 'Rabeprazole Sod_Tab E/C 10mg            '
 'Rabeprazole Sod_Tab E/C 20mg            '
 'Pariet_Tab E/C 20mg                     '
 'Omeprazole_Tab Disper 40mg (E/C Pellets)'
 'Nexium_Tab 40mg                         '
 'Zoton_FasTab Tab 15mg                   '
 'Omeprazole_Tab E/C 40mg                 '
 'Losec_Cap E/C 40mg                      '
 'Losec MUPS_Tab Disper 20mg (E/C Pellets)'
 'Esomeprazole_Cap E/C 40mg               '
 'Omeprazole_Oral Susp 10mg/5ml           '
 'Esomeprazole_Gran Sach G/R 10mg         '
 'Losec_Cap E/C 10mg                      '
 'Losec MUPS_Tab Disper 40mg (E/C Pellets)'
 'Esomeprazole_Cap E/C 20mg               '
 'Omeprazole_Oral Susp 20mg/5ml           '
 'Pariet_Tab E/C 10mg                     '
 'Nexium_Gran Sach G/R 10mg               '
 'Lansoprazole_Oral Susp 15mg/5ml         '
 'Omeprazole_Oral Susp 5mg/5ml            '
 'Naproxen/Esomeprazole_Tab 500mg/20mg M/R'
 'Ketoprofen/Omeprazole_Cap 100mg/20mg M/R'
 'Ketoprofen/Omeprazole_Cap 200mg/20mg M/R'
 'Omeprazole_Liq Spec 25mg/5ml            '
 'Omeprazole_Oral Susp 40mg/5ml           '
 'Lansoprazole_Liq Spec 10mg/5ml          '
 'Lansoprazole_Oral Soln 30mg/5ml         '
 'Lansoprazole_Oral Susp 30mg/5ml         '
 'Lansoprazole_Oral Soln 15mg/5ml         '
 'Lansoprazole_Oral Susp 5mg/5ml          '
 'Omeprazole_Oral Soln 40mg/5ml           '
 'Omeprazole_I/V Inj Pdr 40mg Vl + Dil    '
 'Omeprazole_Oral Soln 10mg/5ml           '
 'Protium_Tab E/C 20mg                    '
 'Omeprazole_Oral Soln 20mg/5ml           '
 'Protium i.v._Inj 40mg Vl (Dry)          '
 'Omeprazole_Liq Spec 15mg/5ml            '
 'Omeprazole_Liq Spec 4mg/5ml             '
 'Zoton_Cap 30mg (E/C Gran)               '
 'Pantoprazole_Inj 40mg Vl                '
 'Omeprazole_Liq Spec 2mg/5ml             '
 'Nexium_Tab 40mg (Arrow Generics Ltd)    '
 'Protium_Tab E/C 40mg                    '
 'Omeprazole_Liq Spec 50mg/5ml            '
 'Lansoprazole_Liq Spec 7.5mg/5ml         '
 'Omeprazole_Liq Spec 8mg/5ml             '
 'Omeprazole_Liq Spec 2.5mg/5ml           '
 'Lansoprazole_Oral Soln 5mg/5ml          '
 'Losec_I/V Inj Pdr 40mg Vl + Dil         ']


Number of practices prescribing each drug in the analysis: 
Omeprazole_Cap E/C 20mg                     8398
Lansoprazole_Cap 30mg (E/C Gran)            8260
Lansoprazole_Cap 15mg (E/C Gran)            8054
Omeprazole_Cap E/C 10mg                     7597
Omeprazole_Cap E/C 40mg                     6968
Lansoprazole_Orodisper Tab 30mg             6934
Esomeprazole_Tab E/C 40mg                   6045
Pantoprazole_Tab E/C 20mg                   6026
Pantoprazole_Tab E/C 40mg                   5971
Esomeprazole_Tab E/C 20mg                   5934
Lansoprazole_Orodisper Tab 15mg             5586
Omeprazole_Tab Disper 20mg (E/C Pellets)    4820
Omeprazole_Tab E/C 20mg                     4680
Rabeprazole Sod_Tab E/C 20mg                4469
Rabeprazole Sod_Tab E/C 10mg                3196
Esomeprazole_Cap E/C 40mg                   3078
Zoton_FasTab Tab 30mg                       3068
Omeprazole_Tab Disper 10mg (E/C Pellets)    2863
Esomeprazole_Cap E/C 20mg                   2726
Losec_Cap E/C 20mg                          2642
Nexium_Tab 20mg                             1975
Zoton_FasTab Tab 15mg                       1834
Nexium_Tab 40mg                             1673
Omeprazole_Tab E/C 40mg                     1294
Omeprazole_Tab E/C 10mg                     1253
Losec MUPS_Tab Disper 20mg (E/C Pellets)    1239
Omeprazole_Tab Disper 40mg (E/C Pellets)    1087
Omeprazole_Oral Susp 10mg/5ml                935
Losec MUPS_Tab Disper 10mg (E/C Pellets)     918
Pariet_Tab E/C 20mg                          748
                                            ... 
Ketoprofen/Omeprazole_Cap 100mg/20mg M/R      74
Lansoprazole_Oral Susp 15mg/5ml               65
Lansoprazole_Oral Susp 30mg/5ml               54
Lansoprazole_Oral Susp 5mg/5ml                44
Nexium_Gran Sach G/R 10mg                     41
Ketoprofen/Omeprazole_Cap 200mg/20mg M/R      41
Omeprazole_Oral Susp 40mg/5ml                 27
Lansoprazole_Oral Soln 30mg/5ml               26
Lansoprazole_Oral Soln 15mg/5ml               21
Omeprazole_Oral Soln 40mg/5ml                 15
Omeprazole_Oral Soln 10mg/5ml                 11
Omeprazole_Oral Soln 20mg/5ml                  7
Omeprazole_Liq Spec 15mg/5ml                   6
Omeprazole_I/V Inj Pdr 40mg Vl + Dil           5
Pantoprazole_Inj 40mg Vl                       5
Losec_I/V Inj Pdr 40mg Vl + Dil                2
Omeprazole_Liq Spec 4mg/5ml                    2
Omeprazole_Liq Spec 50mg/5ml                   2
Nexium_Tab 40mg (Arrow Generics Ltd)           1
Lansoprazole_Oral Soln 5mg/5ml                 1
Zoton_Cap 30mg (E/C Gran)                      1
Lansoprazole_Liq Spec 10mg/5ml                 1
Omeprazole_Liq Spec 25mg/5ml                   1
Lansoprazole_Liq Spec 7.5mg/5ml                1
Protium_Tab E/C 20mg                           1
Omeprazole_Liq Spec 2mg/5ml                    1
Protium i.v._Inj 40mg Vl (Dry)                 1
Omeprazole_Liq Spec 2.5mg/5ml                  1
Protium_Tab E/C 40mg                           1
Omeprazole_Liq Spec 8mg/5ml                    1
dtype: int64


Unique prescribing settings: 
['GP Practice' 'OOH Practice' 'Hospice' 'Public Health Service'
 'Hospital Service' 'Care Home / Nursing Home' 'Other'
 'Community Health Service' 'WIC Practice' 'Urgent & Emergency Care'
 'Prison' 'WIC + OOH Practice']


Number of each practices in each type of prescribing setting: 
GP Practice                 7872
Community Health Service     198
OOH Practice                 175
Other                        118
WIC Practice                  53
Hospital Service              42
Hospice                       40
Care Home / Nursing Home      38
Urgent & Emergency Care       25
Public Health Service         22
Prison                         6
WIC + OOH Practice             4
dtype: int64


Mean badness proportion by prescribing setting: 
Prescribing Setting
Hospice                     0.163125
Community Health Service    0.076678
Hospital Service            0.063845
GP Practice                 0.033155
Other                       0.028925
WIC Practice                0.026210
Care Home / Nursing Home    0.023739
OOH Practice                0.018972
WIC + OOH Practice          0.012500
Public Health Service       0.004785
Urgent & Emergency Care     0.002530
Prison                      0.000000
Name: Proportion, dtype: float64

 non-dispensing practices 

          DP  not_Esomepra     Esomepra   Proportion
count   6857   6857.000000  6857.000000  6857.000000
mean       0    520.192650    17.845268     0.030851
std        0    378.623833    19.995977     0.025094
min    False      1.000000     0.000000     0.000000
25%        0    241.000000     5.000000     0.014388
50%        0    424.000000    11.000000     0.026316
75%        0    709.000000    24.000000     0.041436
max    False   3716.000000   226.000000     0.500000

mean proportion is: 0.031 
median proportion is: 0.026 
variance is: 0.001 
skew is:   3


 dispensing practices: 

         DP  not_Esomepra     Esomepra   Proportion
count  1015   1015.000000  1015.000000  1015.000000
mean      1    763.073892    38.785222     0.048720
std       0    491.345263    36.860861     0.037161
min    True      4.000000     0.000000     0.000000
25%       1    418.000000    14.000000     0.025899
50%       1    664.000000    29.000000     0.039638
75%       1    990.500000    51.000000     0.060291
max    True   4319.000000   308.000000     0.404762

mean proportion is: 0.049 
median proportion is: 0.040 
variance is: 0.001 
skew is:   3

MWW RankSum P for treatments 1 and 2 = 1.64864021392e-75
Z statistic for treatments 1 and 2 = 18.3876873166
Optimization terminated successfully.
         Current function value: 0.127944
         Iterations 9
                          Poisson Regression Results                          
==============================================================================
Dep. Variable:             Proportion   No. Observations:                 7872
Model:                        Poisson   Df Residuals:                     7870
Method:                           MLE   Df Model:                            1
Date:                Mon, 13 Jul 2015   Pseudo R-squ.:                0.003756
Time:                        11:01:21   Log-Likelihood:                -1007.2
converged:                       True   LL-Null:                       -1011.0
                                        LLR p-value:                  0.005854
=================================================================================
                    coef    std err          z      P>|z|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept        -3.4786      0.069    -50.594      0.000        -3.613    -3.344
C(DP)[T.True]     0.4569      0.158      2.893      0.004         0.147     0.767
=================================================================================

IRR
Intercept        0.030851
C(DP)[T.True]    1.579236
dtype: float64

---ACE-i analysis---

Unique drugs in the analysis: 
['Perindopril Erbumine_Tab 8mg            '
 'Ramipril_Cap 5mg                        '
 'Ramipril_Tab 10mg                       '
 'Ramipril_Tab 5mg                        '
 'Lisinopril_Tab 5mg                      '
 'Ramipril_Cap 1.25mg                     '
 'Ramipril_Cap 2.5mg                      '
 'Ramipril_Cap 10mg                       '
 'Enalapril Mal_Tab 5mg                   '
 'Enalapril Mal_Tab 10mg                  '
 'Enalapril Mal_Tab 20mg                  '
 'Lisinopril/Hydchloroth_Tab 20mg/12.5mg  '
 'Lisinopril/Hydchloroth_Tab 10mg/12.5mg  '
 'Lisinopril_Tab 2.5mg                    '
 'Lisinopril_Tab 10mg                     '
 'Lisinopril_Tab 20mg                     '
 'Perindopril Erbumine_Tab 2mg            '
 'Perindopril Erbumine_Tab 4mg            '
 'Trandolapril_Cap 500mcg                 '
 'Trandolapril_Cap 2mg                    '
 'Trandolapril_Cap 4mg                    '
 'Perindopril Argin/Indapam_Tab 5mg/1.25mg'
 'Captopril_Tab 25mg                      '
 'Captopril_Tab 50mg                      '
 'Enalapril Mal_Tab 2.5mg                 '
 'Ramipril_Tab 1.25mg                     '
 'Cilazapril_Tab 5mg                      '
 'Zestril_Tab 20mg                        '
 'Innovace_Tab 5mg                        '
 'Zestril_Tab 10mg                        '
 'Quinapril HCl_Tab 10mg                  '
 'Ramipril_Tab 2.5mg                      '
 'Tritace_Tab 10mg                        '
 'Enalapril/Hydchloroth_Tab 20mg/12.5mg   '
 'Trandolapril_Cap 1mg                    '
 'Zestril_Tab 5mg                         '
 'Ramipril_Titration Pack (Tab 2.5/5/10mg)'
 'Felodipine/Ramipril_Tab 5mg/5mg M/R     '
 'Imidapril HCl_Tab 10mg                  '
 'Captopril_Liq Spec 12.5mg/5ml           '
 'Quinapril HCl_Tab 40mg                  '
 'Ramipril_Oral Soln 2.5mg/5ml S/F        '
 'Captopril_Tab 12.5mg                    '
 'Tritace_Tab 5mg                         '
 'Perindopril Arginine_Tab 10mg           '
 'Coversyl Arginine_Tab 5mg               '
 'Coversyl Arginine Plus_Tab              '
 'Capoten_Tab 25mg                        '
 'Tritace_Tab 2.5mg                       '
 'Perindopril Arginine_Tab 2.5mg          '
 'Innovace_Tab 20mg                       '
 'Perindopril Arginine_Tab 5mg            '
 'Fosinopril Sod_Tab 10mg                 '
 'Fosinopril Sod_Tab 20mg                 '
 'Coversyl Arginine_Tab 10mg              '
 'Quinapril HCl_Tab 5mg                   '
 'Quinapril HCl_Tab 20mg                  '
 'Innovace_Tab 10mg                       '
 'Lisinopril_Oral Soln 5mg/5ml            '
 'Tritace_Titration Pack (Tab 2.5/5/10mg) '
 'Quinapril HCl/Hydchloroth_Tab 10/12.5mg '
 'Imidapril HCl_Tab 20mg                  '
 'Felodipine/Ramipril_Tab 2.5mg/2.5mg M/R '
 'Perindopril/Amlodipine_Tab 8mg/10mg     '
 'Innovace_Tab 2.5mg                      '
 'Coversyl Arginine_Tab 2.5mg             '
 'Enalapril Mal_Oral Soln 5mg/5ml         '
 'Imidapril HCl_Tab 5mg                   '
 'Captopril_Oral Soln 5mg/5ml S/F         '
 'Lisinopril_Oral Soln 2.5mg/5ml          '
 'Accupro_Tab 10mg                        '
 'Comprilan 6cm x 5m Short Stch Compress B'
 'Comprilan 8cm x 5m Short Stch Compress B'
 'Comprilan 10cm x 5m Short Stch Compress '
 'Moexipril HCl_Tab 15mg                  '
 'Coversyl_Tab 4mg                        '
 'Ramipril_Liq Spec 10mg/5ml              '
 'Accupro_Tab 40mg                        '
 'Ramipril_Liq Spec 5mg/5ml               '
 'Lisinopril_Oral Soln 20mg/5ml           '
 'Coversyl_Tab 8mg                        '
 'Ramipril_Liq Spec 2.5mg/5ml             '
 'Lisinopril_Oral Susp 5mg/5ml            '
 'Perindopril Tosilate_Tab 10mg           '
 'Comprilan 12cm x 5m Short Stch Compress '
 'Perindopril/Amlodipine_Tab 4mg/5mg      '
 'Quinil_Tab 20mg                         '
 'Coversyl_Tab 2mg                        '
 'Enalapril Mal_Oral Susp 5mg/5ml         '
 'Captopril_Liq Spec 25mg/5ml             '
 'Captopril_Oral Soln 25mg/5ml S/F        '
 'Perindopril/Amlodipine_Tab 8mg/5mg      '
 'Lisinopril_Oral Susp 2.5mg/5ml          '
 'Perindopril Erbumine_Oral Susp 4mg/5ml  '
 'Accupro_Tab 20mg                        '
 'Noyada_Oral Soln 25mg/5ml               '
 'Tanatril_Tab 20mg                       '
 'Perindopril Erbumine_Oral Soln 4mg/5ml  '
 'Tritace_Tab 1.25mg                      '
 'Perindopril/Indapamide_Tab 5mg/1.25mg   '
 'Cilazapril_Tab 2.5mg                    '
 'Captopril_Liq Spec 3mg/5ml              '
 'Moexipril HCl_Tab 7.5mg                 '
 'Lisinopril_Liq Spec 7.5mg/5ml           '
 'Tanatril_Tab 5mg                        '
 'Tanatril_Tab 10mg                       '
 'Enalapril Mal_Liq Spec 10mg/5ml         '
 'Accupro_Tab 5mg                         '
 'Perindopril Tosilate_Tab 2.5mg          '
 'Perindopril Tosilate_Tab 5mg            '
 'Ramipril_Oral Soln 5mg/5ml              '
 'Lisinopril_Liq Spec 40mg/5ml            '
 'Captopril_Cap 2mg                       '
 'Noyada_Oral Soln 5mg/5ml                '
 'Coversyl Plus_Tab                       '
 'Captopril_Liq Spec 5mg/5ml              '
 'Ramipril_Liq Spec 1.25mg/5ml            '
 'Perindopril Erbum/Indapam_Tab 4mg/1.25mg'
 'Perindopril Erbumine_Liq Spec 8mg/5ml   '
 'Enalapril Mal_Liq Spec 1.25mg/5ml       '
 'Captopril_Liq Spec 10mg/5ml             '
 'Lisinopril_Oral Susp 20mg/5ml           '
 'Perindopril/Amlodipine_Tab 4mg/10mg     '
 'Enalapril Mal_Liq Spec 2.5mg/5ml        '
 'Quinil_Tab 40mg                         '
 'Captopril_Liq Spec 6.25mg/5ml           '
 'Captopril_Liq Spec 8mg/5ml              '
 'Captopril_Liq Spec 20mg/5ml             '
 'Enalapril Mal_Liq Spec 15mg/5ml         '
 'Perdix_Tab 15mg                         ']


Number of practices prescribing each drug in the analysis: 
Ramipril_Cap 5mg                            8025
Ramipril_Cap 2.5mg                          8013
Ramipril_Cap 10mg                           7962
Ramipril_Cap 1.25mg                         7868
Lisinopril_Tab 20mg                         7744
Lisinopril_Tab 10mg                         7731
Lisinopril_Tab 5mg                          7561
Perindopril Erbumine_Tab 4mg                7515
Perindopril Erbumine_Tab 8mg                7394
Perindopril Erbumine_Tab 2mg                7115
Enalapril Mal_Tab 20mg                      7057
Lisinopril_Tab 2.5mg                        6881
Enalapril Mal_Tab 10mg                      6723
Enalapril Mal_Tab 5mg                       5887
Ramipril_Tab 10mg                           4495
Enalapril Mal_Tab 2.5mg                     3768
Ramipril_Tab 5mg                            3683
Ramipril_Tab 2.5mg                          3484
Lisinopril/Hydchloroth_Tab 20mg/12.5mg      3069
Ramipril_Tab 1.25mg                         2493
Captopril_Tab 25mg                          2187
Captopril_Tab 50mg                          2047
Lisinopril/Hydchloroth_Tab 10mg/12.5mg      2037
Perindopril Argin/Indapam_Tab 5mg/1.25mg    2004
Trandolapril_Cap 2mg                        1777
Trandolapril_Cap 4mg                        1512
Quinapril HCl_Tab 20mg                      1499
Quinapril HCl_Tab 40mg                      1236
Captopril_Tab 12.5mg                        1096
Quinapril HCl_Tab 10mg                      1035
                                            ... 
Perindopril Erbumine_Liq Spec 8mg/5ml          6
Captopril_Liq Spec 10mg/5ml                    6
Accupro_Tab 5mg                                6
Perindopril/Amlodipine_Tab 4mg/10mg            5
Lisinopril_Oral Susp 2.5mg/5ml                 5
Lisinopril_Liq Spec 7.5mg/5ml                  5
Ramipril_Liq Spec 1.25mg/5ml                   5
Coversyl_Tab 2mg                               5
Enalapril Mal_Liq Spec 1.25mg/5ml              5
Captopril_Liq Spec 12.5mg/5ml                  4
Coversyl Plus_Tab                              4
Enalapril Mal_Liq Spec 10mg/5ml                4
Cilazapril_Tab 2.5mg                           4
Perindopril Tosilate_Tab 2.5mg                 4
Tanatril_Tab 5mg                               2
Coversyl_Tab 8mg                               2
Lisinopril_Liq Spec 40mg/5ml                   2
Ramipril_Oral Soln 5mg/5ml                     2
Lisinopril_Oral Susp 20mg/5ml                  2
Quinil_Tab 20mg                                2
Quinil_Tab 40mg                                1
Captopril_Liq Spec 3mg/5ml                     1
Perdix_Tab 15mg                                1
Enalapril Mal_Liq Spec 15mg/5ml                1
Captopril_Liq Spec 6.25mg/5ml                  1
Enalapril Mal_Liq Spec 2.5mg/5ml               1
Captopril_Liq Spec 20mg/5ml                    1
Captopril_Cap 2mg                              1
Perindopril Erbum/Indapam_Tab 4mg/1.25mg       1
Captopril_Liq Spec 8mg/5ml                     1
dtype: int64


Unique prescribing settings: 
['GP Practice' 'Public Health Service' 'Care Home / Nursing Home' 'Other'
 'Community Health Service' 'OOH Practice' 'WIC Practice' 'Hospice'
 'Hospital Service' 'Urgent & Emergency Care' 'Prison' 'WIC + OOH Practice'
 'Optometry Service']


Number of each practices in each type of prescribing setting: 
GP Practice                 7856
Community Health Service     140
OOH Practice                 125
Other                         58
Care Home / Nursing Home      32
WIC Practice                  31
Hospital Service              20
Public Health Service         14
Urgent & Emergency Care        9
Hospice                        7
Prison                         2
WIC + OOH Practice             1
Optometry Service              1
dtype: int64


Mean badness proportion by prescribing setting: 
Prescribing Setting
Public Health Service       0.073593
Urgent & Emergency Care     0.064815
Care Home / Nursing Home    0.031250
Other                       0.022989
WIC Practice                0.011322
GP Practice                 0.011070
OOH Practice                0.011027
Community Health Service    0.008730
WIC + OOH Practice          0.000000
Prison                      0.000000
Optometry Service           0.000000
Hospital Service            0.000000
Hospice                     0.000000
Name: Proportion, dtype: float64

 non-dispensing practices 

          DP  not_Captopri     Captopri   Proportion
count   6842   6842.000000  6842.000000  6842.000000
mean       0    425.651125     4.375037     0.010546
std        0    304.904500     5.959367     0.013275
min    False      1.000000     0.000000     0.000000
25%        0    207.250000     1.000000     0.002520
50%        0    353.000000     3.000000     0.006993
75%        0    568.000000     6.000000     0.013699
max    False   2800.000000    77.000000     0.265432

mean proportion is: 0.011 
median proportion is: 0.007 
variance is: 0.000 
skew is:   4


 dispensing practices: 

         DP  not_Captopri     Captopri   Proportion
count  1014   1014.000000  1014.000000  1014.000000
mean      1    673.721893     9.908284     0.014608
std       0    412.129478    43.286420     0.045241
min    True      8.000000     0.000000     0.000000
25%       1    379.250000     2.000000     0.003314
50%       1    574.000000     4.000000     0.006445
75%       1    880.500000     8.000000     0.011696
max    True   3526.000000  1123.000000     0.684426

mean proportion is: 0.015 
median proportion is: 0.006 
variance is: 0.002 
skew is:   9

MWW RankSum P for treatments 1 and 2 = 0.903117345526
Z statistic for treatments 1 and 2 = -0.121724328027
Optimization terminated successfully.
         Current function value: 0.054860
         Iterations 10
                          Poisson Regression Results                          
==============================================================================
Dep. Variable:             Proportion   No. Observations:                 7856
Model:                        Poisson   Df Residuals:                     7854
Method:                           MLE   Df Model:                            1
Date:                Mon, 13 Jul 2015   Pseudo R-squ.:                0.001406
Time:                        11:01:34   Log-Likelihood:                -430.98
converged:                       True   LL-Null:                       -431.59
                                        LLR p-value:                    0.2706
=================================================================================
                    coef    std err          z      P>|z|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept        -4.5520      0.118    -38.667      0.000        -4.783    -4.321
C(DP)[T.True]     0.3259      0.285      1.142      0.253        -0.233     0.885
=================================================================================

IRR
Intercept        0.010546
C(DP)[T.True]    1.385244
dtype: float64

---ARB-II analysis---

Unique drugs in the analysis: 
['Irbesartan_Tab 300mg                    '
 'Candesartan Cilexetil_Tab 2mg           '
 'Valsartan_Cap 40mg                      '
 'Olmetec_Tab 20mg                        '
 'Candesartan Cilexetil_Tab 8mg           '
 'Irbesartan/Hydchloroth_Tab 150mg/12.5mg '
 'Irbesartan/Hydchloroth_Tab 300mg/12.5mg '
 'Olmesartan Medoxomil_Tab 20mg           '
 'Olmesartan Medoxomil_Tab 40mg           '
 'Candesartan Cilexetil_Tab 4mg           '
 'Candesartan Cilexetil_Tab 16mg          '
 'Candesartan Cilexetil_Tab 32mg          '
 'Irbesartan_Tab 75mg                     '
 'Irbesartan_Tab 150mg                    '
 'Losartan Pot_Tab 25mg                   '
 'Losartan Pot_Tab 50mg                   '
 'Losartan Pot_Tab 100mg                  '
 'Losartan Pot/Hydchloroth_Tab 50mg/12.5mg'
 'Losartan Pot/Hydchloroth_Tab 100mg/25mg '
 'Losartan Pot/Hydchloroth_Tab 100/12.5mg '
 'Telmisartan_Tab 40mg                    '
 'Telmisartan_Tab 80mg                    '
 'Telmisartan_Tab 20mg                    '
 'Telmisartan/Hydchloroth_Tab 80mg/12.5mg '
 'MicardisPlus_Tab 80mg/12.5mg            '
 'Valsartan_Cap 80mg                      '
 'Valsartan_Cap 160mg                     '
 'Valsartan/Hydchloroth_Tab 160mg/12.5mg  '
 'Valsartan/Hydchloroth_Tab 160mg/25mg    '
 'Eprosartan_Tab 300mg                    '
 'Eprosartan_Tab 600mg                    '
 'Valsartan/Hydchloroth_Tab 80mg/12.5mg   '
 'Amias_Tab 16mg                          '
 'Irbesartan/Hydchloroth_Tab 300mg/25mg   '
 'Amias_Tab 8mg                           '
 'Losartan Pot_Tab 12.5mg                 '
 'Cozaar_Tab 100mg                        '
 'Telmisartan/Hydchloroth_Tab 80mg/25mg   '
 'Valsartan_Tab 40mg                      '
 'CoAprovel_Tab 300mg/12.5mg              '
 'Olmesartan Medoxomil_Tab 10mg           '
 'Cozaar_Tab 50mg                         '
 'Cozaar_Oral Susp 2.5mg/ml               '
 'Diovan_Cap 80mg                         '
 'Eprosartan_Tab 400mg                    '
 'Cozaar-Comp_Tab 50mg/12.5mg             '
 'Valsartan_Tab 320mg                     '
 'CoAprovel_Tab 150mg/12.5mg              '
 'Aprovel_Tab 150mg                       '
 'Cozaar-Comp_Tab 100mg/12.5mg            '
 'MicardisPlus_Tab 40mg/12.5mg            '
 'Amias_Tab 2mg                           '
 'Amlodipine/Valsartan_Tab 5mg/160mg      '
 'Amlodipine/Valsartan_Tab 10mg/160mg     '
 'Olmesartan Medox/Hydchloroth_Tab 40/12.5'
 'Amias_Tab 4mg                           '
 'Amias_Tab 32mg                          '
 'Aprovel_Tab 300mg                       '
 'Telmisartan/Hydchloroth_Tab 40mg/12.5mg '
 'Olmesartan Medox/Hydchloroth_Tab 20/12.5'
 'Amlodipine/Valsartan_Tab 5mg/80mg       '
 'Co-Diovan_Tab 160mg/25mg                '
 'Co-Diovan_Tab 80mg/12.5mg               '
 'Olmetec_Tab 40mg                        '
 'Olmetec Plus_Tab 20mg/12.5mg            '
 'Aprovel_Tab 75mg                        '
 'Micardis_Tab 40mg                       '
 'Cozaar-Comp_Tab 100mg/25mg              '
 'Micardis_Tab 80mg                       '
 'Olmesartan Medox/Amlodipine_Tab 20mg/5mg'
 'Olmesartan Medox/Amlodipine_Tab 40mg/5mg'
 'Olmesartan Medox/Amlodipine_Tab40mg/10mg'
 'Diovan_Cap 160mg                        '
 'Olmesartan Medox/Hydchloroth_Tab 20/25mg'
 'Olmetec Plus_Tab 20mg/25mg              '
 'Teveten_Tab 300mg                       '
 'Cozaar_Tab 25mg                         '
 'Olmesartan/Amlodipine/Hydchloroth_Tab   '
 'Olmetec_Tab 10mg                        '
 'Losartan Pot_Oral Susp 12.5mg/5ml S/F   '
 'Co-Diovan_Tab 160mg/12.5mg              '
 'Micardis_Tab 20mg                       '
 'MicardisPlus_Tab 80mg/25mg              '
 'Diovan_Cap 40mg                         '
 'CoAprovel_Tab 300mg/25mg                '
 'Azilsartan Medoxomil_Tab 40mg           '
 'Losartan Pot_Oral Susp 50mg/5ml         '
 'Valsartan_Tab 160mg                     '
 'Losartan Pot_Oral Soln 50mg/5ml         '
 'Cozaar_Tab 12.5mg                       '
 'Teveten_Tab 600mg                       '
 'Losartan Pot_Liq Spec 100mg/5ml         '
 'Azilsartan Medoxomil_Tab 20mg           '
 'Olmetec Plus_Tab 40mg/12.5mg            '
 'Irbesartan_Liq Spec 150mg/5ml           '
 'Edarbi_Tab 40mg                         '
 'Edarbi_Tab 80mg                         '
 'Irbesartan_Liq Spec 300mg/5ml           '
 'Azilsartan Medoxomil_Tab 80mg           '
 'Olmesartan Medoxomil_Liq Spec 10mg/5ml  '
 'Valsartan_Tab 80mg                      '
 'Diovan_Tab 320mg                        '
 'Valsartan_Liq Spec 160mg/5ml            '
 'Candesartan Cilexetil_Liq Spec 8mg/5ml  ']


Number of practices prescribing each drug in the analysis: 
Losartan Pot_Tab 50mg                       7856
Losartan Pot_Tab 100mg                      7779
Losartan Pot_Tab 25mg                       7559
Candesartan Cilexetil_Tab 8mg               7558
Candesartan Cilexetil_Tab 4mg               7407
Candesartan Cilexetil_Tab 16mg              7336
Irbesartan_Tab 150mg                        6964
Irbesartan_Tab 300mg                        6909
Candesartan Cilexetil_Tab 32mg              6211
Candesartan Cilexetil_Tab 2mg               5994
Irbesartan_Tab 75mg                         5738
Valsartan_Cap 80mg                          4765
Valsartan_Cap 160mg                         4167
Losartan Pot_Tab 12.5mg                     4047
Telmisartan_Tab 40mg                        3431
Telmisartan_Tab 80mg                        3360
Olmesartan Medoxomil_Tab 20mg               3113
Losartan Pot/Hydchloroth_Tab 50mg/12.5mg    3097
Losartan Pot/Hydchloroth_Tab 100mg/25mg     2905
Olmesartan Medoxomil_Tab 10mg               2841
Valsartan_Cap 40mg                          2724
Irbesartan/Hydchloroth_Tab 300mg/12.5mg     2450
Telmisartan_Tab 20mg                        2193
Olmesartan Medoxomil_Tab 40mg               2169
Losartan Pot/Hydchloroth_Tab 100/12.5mg     1769
Valsartan/Hydchloroth_Tab 160mg/12.5mg      1731
Irbesartan/Hydchloroth_Tab 150mg/12.5mg     1679
Eprosartan_Tab 600mg                        1613
Valsartan/Hydchloroth_Tab 80mg/12.5mg       1149
Telmisartan/Hydchloroth_Tab 80mg/12.5mg     1120
                                            ... 
CoAprovel_Tab 300mg/25mg                      96
Diovan_Cap 80mg                               94
Teveten_Tab 600mg                             90
Losartan Pot_Oral Susp 12.5mg/5ml S/F         89
Olmetec Plus_Tab 20mg/12.5mg                  83
Olmetec_Tab 40mg                              78
Teveten_Tab 300mg                             54
Cozaar_Tab 12.5mg                             43
MicardisPlus_Tab 80mg/25mg                    39
Olmetec Plus_Tab 40mg/12.5mg                  36
Olmesartan/Amlodipine/Hydchloroth_Tab         27
Olmetec Plus_Tab 20mg/25mg                    24
Losartan Pot_Oral Susp 50mg/5ml               18
Azilsartan Medoxomil_Tab 40mg                 17
Losartan Pot_Liq Spec 100mg/5ml               16
Losartan Pot_Oral Soln 50mg/5ml               14
Cozaar_Oral Susp 2.5mg/ml                     11
Diovan_Cap 40mg                                9
Azilsartan Medoxomil_Tab 80mg                  8
Diovan_Tab 320mg                               4
Edarbi_Tab 40mg                                3
Valsartan_Tab 160mg                            2
Azilsartan Medoxomil_Tab 20mg                  2
Irbesartan_Liq Spec 150mg/5ml                  2
Olmesartan Medoxomil_Liq Spec 10mg/5ml         2
Edarbi_Tab 80mg                                1
Valsartan_Liq Spec 160mg/5ml                   1
Valsartan_Tab 80mg                             1
Candesartan Cilexetil_Liq Spec 8mg/5ml         1
Irbesartan_Liq Spec 300mg/5ml                  1
dtype: int64


Unique prescribing settings: 
['GP Practice' 'Public Health Service' 'Care Home / Nursing Home' 'Other'
 'OOH Practice' 'WIC Practice' 'Hospice' 'Hospital Service'
 'Community Health Service' 'Urgent & Emergency Care' 'Prison'
 'WIC + OOH Practice']


Number of each practices in each type of prescribing setting: 
GP Practice                 7839
OOH Practice                  96
Community Health Service      81
Other                         38
WIC Practice                  27
Care Home / Nursing Home      23
Hospital Service              15
Urgent & Emergency Care        7
Hospice                        5
Public Health Service          4
WIC + OOH Practice             2
Prison                         2
dtype: int64


Mean badness proportion by prescribing setting: 
Prescribing Setting
Urgent & Emergency Care     0.285714
WIC + OOH Practice          0.250000
WIC Practice                0.237654
OOH Practice                0.127206
Hospital Service            0.100000
GP Practice                 0.098191
Care Home / Nursing Home    0.097826
Other                       0.082707
Community Health Service    0.062096
Public Health Service       0.019231
Prison                      0.000000
Hospice                     0.000000
Name: Proportion, dtype: float64

 non-dispensing practices 

          DP  not_Azilsart     Azilsart   Proportion
count   6825   6825.000000  6825.000000  6825.000000
mean       0    167.290696    15.617875     0.086945
std        0    123.461754    21.568036     0.083205
min    False      0.000000     0.000000     0.000000
25%        0     79.000000     4.000000     0.034169
50%        0    138.000000    10.000000     0.064327
75%        0    225.000000    19.000000     0.113208
max    False   1131.000000   526.000000     1.000000

mean proportion is: 0.087 
median proportion is: 0.064 
variance is: 0.007 
skew is:   3


 dispensing practices: 

         DP  not_Azilsart     Azilsart   Proportion
count  1014   1014.000000  1014.000000  1014.000000
mean      1    250.527613    57.179487     0.173886
std       0    157.738299    79.855888     0.179669
min    True      1.000000     0.000000     0.000000
25%       1    137.000000    11.000000     0.051958
50%       1    220.000000    28.000000     0.105270
75%       1    336.750000    68.000000     0.234102
max    True   1458.000000   817.000000     0.942169

mean proportion is: 0.174 
median proportion is: 0.105 
variance is: 0.032 
skew is:   2

MWW RankSum P for treatments 1 and 2 = 3.04999821372e-55
Z statistic for treatments 1 and 2 = 15.655439314
Optimization terminated successfully.
         Current function value: 0.280453
         Iterations 8
                          Poisson Regression Results                          
==============================================================================
Dep. Variable:             Proportion   No. Observations:                 7839
Model:                        Poisson   Df Residuals:                     7837
Method:                           MLE   Df Model:                            1
Date:                Mon, 13 Jul 2015   Pseudo R-squ.:                 0.01283
Time:                        11:01:46   Log-Likelihood:                -2198.5
converged:                       True   LL-Null:                       -2227.1
                                        LLR p-value:                 4.002e-14
=================================================================================
                    coef    std err          z      P>|z|      [95.0% Conf. Int.]
---------------------------------------------------------------------------------
Intercept        -2.4425      0.041    -59.498      0.000        -2.523    -2.362
C(DP)[T.True]     0.6931      0.086      8.081      0.000         0.525     0.861
=================================================================================

IRR
Intercept        0.086945
C(DP)[T.True]    1.999965
dtype: float64

In [ ]: