<jupyter_start><jupyter_text>Q3<jupyter_code>import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
data = pd.read_csv('extract_medium.csv',sep=';')
data.head(1)
Genders = ['Male','Female']
Education = ['Not in universe (Under 3 years)','No schooling completed','Nursery school to 4th grade',\
             '5th grade or 6th grade','7th,8th grade','9th grade','10th grade','11th grade','12th grade,no diploma',\
'High school graduate','college,less than 1 year','college 1+ years, no degree','Associate degree','Bachelor,s degree',\
'Master.s degree','Professional degree','Doctorate degree']
MarriageState=['married','Widowed','Divorced','Separated','Never married']
table = pd.pivot_table(data,values='Earnings',index=['Sex', 'Education'],aggfunc=np.mean)
##OR###
temp1 = data.groupby(['Sex', 'Education']).Earnings.mean()
temp1
temp1 = temp1.values
test=temp1.reshape(2,17)
test.shape
fig = plt.figure()
ax = fig.add_subplot(111)
ax.pcolor(test,cmap=plt.cm.Reds,vmin=np.min(test), vmax=np.max(test))
ax.set_yticks([1,2])
ax.set_yticklabels(Genders)
ax.set_xticks(range(1,18))
ax.set_xticklabels(Education)
for tick in ax.get_xticklabels():
    tick.set_rotation(90)
plt.gcf().subplots_adjust(bottom=0.20)
ax.set_title('Heat map of average Earnings Gender Vs Education')
plt.show()
plt.close()<jupyter_output><empty_output><jupyter_text>Q4<jupyter_code>table = pd.pivot_table(data,values='Earnings',index=['Sex', 'Marriage'],aggfunc=np.mean)
table = table.values
test=table.reshape(2,5)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.pcolor(test,cmap=plt.cm.Reds,vmin=np.min(test), vmax=np.max(test))
ax.set_yticks([1,2])
ax.set_yticklabels(Genders)
ax.set_xticks(range(6))
ax.set_xticklabels(MarriageState)
for tick in ax.get_xticklabels():
    tick.set_rotation(45)
plt.gcf().subplots_adjust(bottom=0.20)
ax.set_title('Heat map of average Earnings Gender Vs Mariage')
plt.show()
plt.close()<jupyter_output><empty_output><jupyter_text>Q5<jupyter_code>table = pd.pivot_table(data,values='Earnings',index=['Sex', 'Marriage','Hours'],aggfunc=np.mean)
type(table)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup