Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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')
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
    def test_country_data_load(self):

        df = gdp.load_country_data('../countries.csv')
        self.assertEqual(len(df), 194)
        self.assertEqual(df.shape, (194, 2))
        self.assertRaises(SystemExit, gdp.load_country_data, 'wrongfile.csv')
Ejemplo n.º 7
0
 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')
Ejemplo n.º 8
0
 def test_country_data_load(self):
     
     df = gdp.load_country_data('../countries.csv')
     self.assertEqual(len(df), 194)
     self.assertEqual(df.shape,(194,2))
     self.assertRaises(SystemExit,gdp.load_country_data,'wrongfile.csv')