Question
math = pd.read_csv(Maths.csv) average = 10 math['Above Average'] = ['y' if x > average else 'n' for x in math['G3']] above_avg = sum(math['Above Average'] ==
math = pd.read_csv("Maths.csv")
average = 10
math['Above Average'] = ['y' if x > average else 'n' for x in math['G3']]
above_avg = sum(math['Above Average'] == 'y')
below_avg = sum(math['Above Average'] == 'n')
print(f'Number of students above average: {above_avg}')
print(f'Number of students below average: {below_avg}')
math[math['Above Average'] == 'y'].hist(column='age', color='pink')
plt.title('Age of people with grade above average')
plt.xlabel("Age")
plt.ylabel("Frequency")
math[math['Above Average'] == 'n'].hist(column='age', color='black')
plt.title('Age of people with grade below average')
plt.xlabel("Age")
plt.ylabel("Frequency")
plt.show()
I need to write a code with the same functionality as the one above, but using pyplot.express
It should look similar to : fig=px.histogram(df, x=' ', color=' ' , barnorm= 'percent')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started