Question: import pandas as pd import seaborn as sns import matplotlib.pyplot as plt % matplotlib inline pd . options.display.float _ format = ' { : .
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
matplotlib inline
pdoptions.display.floatformat :fformat
def producesummarytabledfraw pdreadexcelWHRChapterOnlineData.xls sheetname'Table
:
colstoinclude country 'year', 'Life Ladder',
'Positive affect','Negative affect',
'Log GDP per capita', 'Social support',
'Healthy life expectancy at birth',
'Freedom to make life choices',
'Generosity', 'Perceptions of corruption'
df dfrawcolstoinclude
columnrenaming count: N 'mean': 'Mean', std: Std Dev. 'min': 'Min. 'max': 'Max.
columnorder MeanStd Dev. 'Min. 'Max.N
dftransposed dfdescribeT
dftransposed
dftransposed dftransposeddropyear
dftransposed
dfdropped dftransposeddrop axis
dfdropped
dfrenamed dfdroppedrenamecolumnscolumnrenaming
dfsummary dfrenamed
dfsummaryN dfsummaryNastypeint
return dfsummary
dfsummarynew producesummarytable
df dfsummarynewcolumnorder
df
In the empty code cell below, do the following:
Create three new dataframes for each of the year ranges associated with Tables and by extracting the appropriate set of years. Using the function you wrote above, create a summary table for each dataframe your function takes a dataframe as input Assign the resulting summary tables to the names dfsummary dfsummary and dfsummary
The remaining three code cells below are populated with the table names dfsummary dfsummary and dfsummary Once you have created these summary tables as outlined above, execute these cells to compare your tables with the corresponding tables in WHR Appendix
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
