<jupyter_start><jupyter_text>Analysis of STAR-PU Data<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import math
import numpy as np
import os
%matplotlib inline
os.chdir("..")
current_working_dir = os.getcwd()
print(current_working_dir)
data = pd.read_csv(r'output/measures/measure_STARPU_antibiotics.csv')
data
data.info()
#data['practice'].value_counts().sort_index()

data['practice'].value_counts().sort_index().plot(kind='bar', figsize=(10, 5), rot=0)
plt.xlabel('Practice')
plt.ylabel('Frequency')
plt.title('Frequency of practices')
#plt.xlim(0, 100)
plt.ylim(0, 700)
plt.grid()
plt.savefig(r'output/hospitalisation_risk/practices.png', edgecolor='none')
plt.show()
current_working_dir = os.getcwd()
print(current_working_dir)
#data['sex'].value_counts().sort_index()

data['sex'].value_counts().sort_index().plot(kind='bar', figsize=(3, 5), rot=0)
plt.xlabel('Sex')
plt.ylabel('Frequency')
plt.title('Frequency of sexes')
#plt.xlim(0, 100)
plt.ylim(0, 10000)
plt.grid()
print(data['sex'].value_counts().sort_index())
plt.savefig(r'output/hospitalisation_risk/sexes.png', edgecolor='none')
plt.show()
#data['age_cat'].value_counts().sort_index()

data['age_cat'].value_counts().sort_index().plot(kind='bar', figsize=(10, 5), rot=0)
plt.xlabel('Age category')
plt.ylabel('Frequency')
plt.title('Frequency of age categories')
#plt.xlim(0, 100)
plt.ylim(0, 2500)
plt.grid()
print(data['age_cat'].value_counts().sort_index())
plt.savefig(r'output/hospitalisation_risk/age_categories.png', edgecolor='none')
plt.show()
sns.distplot(data['antibacterial_prescriptions'], hist=True, kde=True, 
             bins=15, color = 'blue', 
             hist_kws={'edgecolor':'black'},
             kde_kws={'linewidth': 2})

plt.xlabel('Number of prescriptions')
#plt.ylabel('Frequency')
plt.title('Antibacterial prescriptions')
#plt.xlim(0, 100)
#plt.ylim(0, 1100)
plt.grid(True)
plt.savefig(r'output/hospitalisation_risk/antibacterial_prescirption.png', edgecolor='none')
plt.show()
data.groupby(['practice'])['population'].sum().plot(kind='bar', figsize=(10, 5))
#plt.ylim(0.5, 2)
plt.xticks(rotation = 0, ha="right")
plt.title("Population of each practice")
plt.xlabel('Practice')
plt.ylabel('Population')
plt.grid()
plt.savefig(r'output/hospitalisation_risk/antibacterial_prescirption_grouped_population.png', edgecolor='none')
plt.show()
sns.distplot(data['population'], hist=True, kde=True, 
             bins=15, color = 'blue', 
             hist_kws={'edgecolor':'black'},
             kde_kws={'linewidth': 2})

plt.xlabel('Population')
#plt.ylabel('Frequency')
plt.title('Population in each practice')
#plt.xlim(0, 100)
#plt.ylim(0, 1100)
plt.grid(True)
plt.savefig(r'output/hospitalisation_risk/population.png', edgecolor='none')
plt.show()
data['date'].value_counts().sort_index().plot(kind='bar', figsize=(10, 5))
plt.ylim(0, 1000)
plt.xticks(rotation = 45, ha="right")
plt.title("Dates of antibiotics practices between 2019-01-01 to 2021-09-01")
plt.xlabel('Dates')
plt.ylabel('Frequency')
plt.grid()
plt.savefig(r'output/hospitalisation_risk/STARPU_barchart.png', edgecolor='none')
plt.show()
data.date.value_counts().sort_index()
data.groupby(['date'])['value'].mean().plot(kind='line', figsize=(10, 5))
plt.ylim(0.5, 2)
plt.xticks(rotation = 45, ha="right")
plt.title("Mean STAR-PU values of each month between 2019-01-01 to 2021-09-01")
plt.xlabel('Month')
plt.ylabel('STAR-PU')
plt.grid()
#plt.xticks(values)
plt.savefig(r'output/hospitalisation_risk/STARPU_linechart.png', edgecolor='none')
plt.show()
data.groupby(['date'])['value'].sum().plot(kind='line', figsize=(10, 5))
plt.ylim(0.5, 600)
plt.xticks(rotation = 45, ha="right")
plt.title("Sum of STAR-PU values of each month between 2019-01-01 to 2021-09-01")
plt.xlabel('Month')
plt.ylabel('STAR-PU')
plt.grid()
#plt.xticks(values)
plt.savefig(r'output/hospitalisation_risk/STARPU_sum_linechart.png', edgecolor='none')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19178427419354838, 'fraction_numerical': 0.03654233870967742, 'mean_word_length': 7.002016129032258, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '652043', 'license': 'MIT', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1446, 'n_words': 232, 'path': 'analysis/starpu.ipynb', 'repo_name': 'opensafely/amr-uom-brit', 'size': '3968'}