def main(): country_file = '../countries.csv' countries = gdp.load_country_data(country_file) income_file = '../indicator gapminder gdp_per_capita_ppp.xlsx' income = gdp.load_gdp_data(income_file) print(income.head()) ExitLoop = False while not ExitLoop: year_from_user = gdp.get_user_input() if year_from_user == 'finish': years = [str(i) for i in range(2007,2013)] print("Saving boxplot and histogram of income per person by region from 2007 to 2012\n") for year in years: merged_data = gdp.merge_by_year(year, countries, income) analysistool = gdp.IncomeAnalysis(merged_data,year) analysistool.plot_boxplot() analysistool.plot_histogram() print("Terminating the program") ExitLoop = True else: gdp.plot_income_distribution_by_year(income, year_from_user)
def main(): country_file = '../countries.csv' countries = gdp.load_country_data(country_file) income_file = '../indicator gapminder gdp_per_capita_ppp.xlsx' income = gdp.load_gdp_data(income_file) print(income.head()) ExitLoop = False while not ExitLoop: year_from_user = gdp.get_user_input() if year_from_user == 'finish': years = [str(i) for i in range(2007, 2013)] print( "Saving boxplot and histogram of income per person by region from 2007 to 2012\n" ) for year in years: merged_data = gdp.merge_by_year(year, countries, income) analysistool = gdp.IncomeAnalysis(merged_data, year) analysistool.plot_boxplot() analysistool.plot_histogram() print("Terminating the program") ExitLoop = True else: gdp.plot_income_distribution_by_year(income, year_from_user)
def test_income_data_load(self): df = gdp.load_gdp_data( '../indicator gapminder gdp_per_capita_ppp.xlsx') self.assertEqual(len(df), 214) self.assertEqual(df.shape, (214, 260)) self.assertRaises(SystemExit, gdp.load_gdp_data, 'wrongfile.xlsx')
def test_merge_function(self): countries = gdp.load_country_data('../countries.csv') income = gdp.load_gdp_data('../indicator gapminder gdp_per_capita_ppp.xlsx') year = '2006' merged_data = gdp.merge_by_year(year, countries, income) self.assertEqual(list(merged_data.columns),['Country', 'Region', 'Income']) self.assertEqual(merged_data.Country[0],'Algeria') self.assertEqual(merged_data.Region[0],'AFRICA') self.assertEqual(int(merged_data.Income[0]),6022)
def test_merge_function(self): countries = gdp.load_country_data('../countries.csv') income = gdp.load_gdp_data( '../indicator gapminder gdp_per_capita_ppp.xlsx') year = '2006' merged_data = gdp.merge_by_year(year, countries, income) self.assertEqual(list(merged_data.columns), ['Country', 'Region', 'Income']) self.assertEqual(merged_data.Country[0], 'Algeria') self.assertEqual(merged_data.Region[0], 'AFRICA') self.assertEqual(int(merged_data.Income[0]), 6022)
def test_income_data_load(self): df = gdp.load_gdp_data('../indicator gapminder gdp_per_capita_ppp.xlsx') self.assertEqual(len(df), 214) self.assertEqual(df.shape,(214,260)) self.assertRaises(SystemExit,gdp.load_gdp_data,'wrongfile.xlsx')