<jupyter_start><jupyter_text>A diagnosis (i.e. a diagnosis code) can be assigned to a patient directly at the time of a hearing evaluation. List the top 5 most common diagnosis codes given to patients at such a point in time along with their frequencies.<jupyter_code>df['diagnosis_code'].value_counts()[:5]
df4= pd.merge(df,df2,on='patient_id')
df4.head(10)<jupyter_output><empty_output><jupyter_text>A diagnosis (i.e. a diagnosis code) can be assigned to a patient directly at the time of a hearing evaluation. List the top 5 most common diagnosis codes given to patients at such a point in time along with their frequencies.<jupyter_code>g= df4.groupby(['diagnosis_code'])
g=g.filter(lambda x: x['patient_id'].count()>=1)
g=g.loc[:,['diagnosis_code','patient_id']]
g=g.groupby(['diagnosis_code']).count()
g.sort_values(by=['patient_id'],ascending=False)[:5]<jupyter_output><empty_output><jupyter_text>In an effort to check that their dataset is `sensible', the client would like to extract the highest number of diagnoses assigned to a single patient. (Both the patient ID and the number of diagnoses need to be included).<jupyter_code>g1= df4.groupby(['patient_id'])
g1=g1.filter(lambda x: x['diagnosis_code'].count()>=1)
g1=g1.loc[:,['patient_id','diagnosis_code']]
g1=g1.groupby(['patient_id']).count()
g1['diagnosis_code']
g1.rename(columns = {'diagnosis_code':'Number of diagnosis'}, inplace = True)
g1.sort_values(by=['Number of diagnosis'],ascending=False)<jupyter_output><empty_output><jupyter_text>A hearing problem is represented in the data as a patient's  everity of Hearing Loss" being one of the following values: Slight, Mild, Moderate, Moderately Severe, Severe, or Profound. The client is interested in the total number of (dierent) people with a hearing problem in comparison to the total number of people who have had a hearing evaluation (both numbers should be stated separately, as well as the % diagnosed having a hearing problem).<jupyter_code>event_dictionary ={'Normal' : 1, 'Mild' : 1, 'Moderate' : 1,'Moderately Severe ':1,'Slight':1,'Profound':1,'Severe':1,'Insufficient Data':1} 

df1['values'] = df1['severity_of_hearing_loss'].map(event_dictionary) 
df1['values'].value_counts()
z= len(df1)
df1.columns
df11 = df1.drop_duplicates(subset='patient_id', keep="first")
y = len(df11)
y
(df1['severity_of_hearing_loss'].value_counts())
y1= (df1['severity_of_hearing_loss'].value_counts())[-2]
y1
(y1/y)*100
df4 = pd.DataFrame({'#Prople having problems': [y1], '#of people with hearing evaluation': [y],'%of the people having problem':[(y1/y)*100]})
df4
df5= pd.merge(df,df2,on='patient_id')
df1.head(10)
df4.head(10)<jupyter_output><empty_output><jupyter_text>Looking specifially at CT imaging, the client would like to know the year group (i.e. you will need to group the ages of encounter into years) which is given the greatest number of CTs.<jupyter_code>df6= pd.merge(df,df2,on='patient_id')
df5=df6.loc[df6['modality'] == 'CT']
df5
import matplotlib.pyplot as plt
plt.hist(df5['diagnosis_age'], bins=10)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup