def answer(): top15 = q1.answer() top15['pop'] = top15['Energy Supply'] / top15['Energy Supply per Capita'] top15['bucket'] = pd.cut(top15['% Renewable'], 5) continents = q11.continentDict() count = top15[['pop', 'bucket']] \ .groupby([lambda country: continents[country], 'bucket']) \ .count() \ .dropna() count.index.rename(['Continent', 'bins'], inplace=True) count.columns = ['count'] return pd.Series(count['count'], index=count.index)
def answer(): top15 = q1.answer() top15['pop'] = top15['Energy Supply'] / top15['Energy Supply per Capita'] print(top15.loc['China', 'pop']) PopEst = top15['pop'].map('{:,}'.format) return PopEst
def answer(): top15 = q1.answer() largest = top15['% Renewable'].nlargest(1) return (largest.index[0], largest.values[0])
def answer(): top15 = q1.answer() top15['pop'] = top15['Energy Supply'] / top15['Energy Supply per Capita'] top15['docs per capita'] = top15['Citable documents'] / top15['pop'] sigma = top15[['Energy Supply per Capita', 'docs per capita']].corr() return sigma.iloc[0, 1]
def answer(): top15 = q1.answer() med = top15['% Renewable'].median() top15.loc[top15['% Renewable'] >= med, 'HighRenew'] = 1 top15.loc[top15['% Renewable'] < med, 'HighRenew'] = 0 return top15.sort_values('Rank')['HighRenew']
def answer(): avgGDP = q1.answer() columns = getGdpColumns() avgGDP = avgGDP[columns].mean(1).sort_values(ascending=False) return avgGDP
def answer(): top15 = q1.answer() top15['pop'] = top15['Energy Supply'] / top15['Energy Supply per Capita'] largest = top15['pop'].nlargest(3) return largest.index[2]
def answer(): top15 = q1.answer() country = q3.answer().index[5] gdp2006 = top15.loc[country, '2006'] gdp2015 = top15.loc[country, '2015'] return gdp2015 - gdp2006
def answer(): top15 = q1.answer() return top15['Energy Supply per Capita'].mean()