Skip to content

Instantly share code, notes, and snippets.

@PranjalDureja0002
Created March 15, 2021 09:31
Show Gist options
  • Save PranjalDureja0002/a6c1d4fe694e6cafc522be1176d074c3 to your computer and use it in GitHub Desktop.
Save PranjalDureja0002/a6c1d4fe694e6cafc522be1176d074c3 to your computer and use it in GitHub Desktop.
data
outpatient_data["age_group"]=pd.cut(outpatient_data.Age, [30,40,50,60,70,80,90,100])
inpatient_data["age_group"]=pd.cut(inpatient_data.Age, [30,40,50,60,70,80,90,100])
fraud_count = outpatient_data['PotentialFraud'].value_counts().to_dict()
outpatient_data['fraud_Count']=outpatient_data['PotentialFraud'].map(age_count)
s1 = inpatient_data['Gender'].value_counts()
s_s1 = sum(s1.tolist())
s2 = outpatient_data['Gender'].value_counts()
s_s2 = sum(s2.tolist())
plt.style.use('fivethirtyeight')
counts = inpatient_data.groupby(['age_group', 'Gender']).Age.count().unstack()
print(counts)
ax = counts.plot(kind='bar',stacked = False, colormap = 'Paired')
total = s_s1
for p in ax.patches:
percentage = '{:.1f}%'.format(100 * p.get_height()/total)
x = p.get_x() + p.get_width() - 0.5
y = p.get_y() + p.get_height()
ax.annotate(percentage, (x, y))
plt.xlabel ('Age Group')
plt.ylabel ('Co-Occurences ')
plt.title('Inpatients In An Age Group Belonging to a specific gender',fontsize=20)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment