Пример #1
0
    def test_graph_generator(self):
        try:
            os.remove('./grade_improvement_nyc.pdf')

        except OSError:
            pass

        cleaned_df = dc.data_loader_and_cleaner('DOHMH_New_York_City_Restaurant_Inspection_Results.csv').cleaned_df
        nyc_grades_dictionary = agg._nyc_grades_by_year(cleaned_df)
        gg.grades_by_year_graph_generator(nyc_grades_dictionary, "nyc")

        self.assertTrue(os.path.isfile('grade_improvement_nyc'))
Пример #2
0
 def test_test_restaurant_grades(self):
     cleaned_df = dc.data_loader_and_cleaner('DOHMH_New_York_City_Restaurant_Inspection_Results.csv').cleaned_df
     with self.assertRaises(TypeError):
         gc.test_restaurant_grades(cleaned_df, 45234635)
Пример #3
0
 def test_data_loader_and_cleaner1(self):
     with self.assertRaises(IOError):
         dc.data_loader_and_cleaner('sdjasd.csv')
Пример #4
0
"""

import data_cleaner as dc #Module with class to clean Data
import graph_generator as gg  #Module with function to generate graph
import aggregated_grades_generator as agg #Module with functions to calculate aggregated metrics
import grades_calculator as gc #Module with functions to calculate improvement metrics.

import warnings

warnings.filterwarnings("ignore") # This is used to avoid printing some Pandas FutureWarnings


try:
    #creates an instance of the data_loader_and_cleaner with the proper route. A cleaned DF is returned
    cleaned_df = dc.data_loader_and_cleaner('DOHMH_New_York_City_Restaurant_Inspection_Results.csv').cleaned_df

    # This function returns the total improvement for NYC required in question 4 of Assignment 10.
    # It sums the test_restaurant_grades function output of each restaurant in the city and prints it.
    gc._nyc_total_restaurant_improvement(cleaned_df)

    # This function returns the total improvement for each borough of NYC required in question 4 of Assignment 10.
    # It sums the test_restaurant_grades function output of each restaurant in each borough and prints it.
    gc._total_restaurant_improvement_by_boro(cleaned_df)

    # The following two functions aggregate the total number of distinct grades/restaurants by year and saves them in
    # two dictionaries, one for the whole city and one for each borough.
    nyc_grades_dictionary = agg._nyc_grades_by_year(cleaned_df)
    boros_grades_dictionary = agg._nyc_boros_grades_by_year(cleaned_df)

    # Next, we generate the chart of the total number of restaurants in New York City for each grade over time.