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'))
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. gg.grades_by_year_graph_generator(nyc_grades_dictionary, "nyc") # Finally, we generate the charts of the total number of restaurants by borough for each grade over time. for boro in boros_grades_dictionary.keys(): if boro == 'STATEN ISLAND': boro_name = 'staten' #This condition was added to produce correct filename for the Staten Island borough graph file required in problem 5 else: boro_name = boro gg.grades_by_year_graph_generator(boros_grades_dictionary[boro], boro_name) except LookupError as e: print str(e)