Beispiel #1
0
def university_crime_explorer(dataframe):
    '''Handles the features of first GUI'''

    GUI.start_user_interface(dataframe)
    university_name = GUI.get_uni()
    branch_name = GUI.get_branch()

    print "Details about %s (%s) is being generated. Please wait..." % (
        university_name, branch_name)

    college_instance = handlers.college_details(dataframe, university_name,
                                                branch_name)
    college_obj = coll.College(college_instance, crimes_obj)

    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj)  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True)  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj)  # Question 3

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, college_obj, pltparam,
                                crime_per_student_without_average,
                                crime_per_student_with_average,
                                crimes_per_student_by_category)

    answers_obj.visualize_answer1()
    answers_obj.pieChart(crime_per_student_with_average)
Beispiel #2
0
def crime_comparisons(dataframe, crimes_obj):
    '''Handles the functionalities of different crime comparisons'''

    GUI4.start_user_interface()
    crime_1, crime_2 = GUI4.get_crimes()
    crimes_per_student_state = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj, overall_average=True)
    crimes_per_student_sector = handlers.average_crimes_per_student_by_category(
        dataframe, 'Sector_desc', crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None,
                                crimes_per_student_state)
    answers_obj.visualize_answer4(crime_1, crime_2)

    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None,
                                crimes_per_student_sector)
    answers_obj.visualize_answer4(crime_1, crime_2)
Beispiel #3
0
def category_wise_crime(dataframe, crimes_obj):
    '''Handles the functionalities of crimes by different categories'''

    GUI3.start_user_interface(dataframe)
    category, specific_choice = GUI3.get_choices()
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, category, crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, None, pltparam, None, None, None)

    bar_chart = answers_obj.simpleBarChart(crimes_per_student_by_category,
                                           specific_choice)

    return bar_chart, specific_choice
Beispiel #4
0
def get_university_crime_details_and_plot(dataframe, college_obj, crimes_obj):
    '''Computes and generates the plots for the university'''

    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj)  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True)  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj, overall_average=True)

    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, college_obj, pltparam,
                                crime_per_student_without_average,
                                crime_per_student_with_average,
                                crimes_per_student_by_category)

    multibar_plot = answers_obj.visualize_answer1()
    pie_chart = answers_obj.pieChart(crime_per_student_with_average)

    return multibar_plot, pie_chart
Beispiel #5
0
if __name__ == '__main__':
    p = pltParam()

    university_name = "Harvard University"

    branch_name = "Main Campus"
    dataframe, crimes_obj = handlers.data_initialization(
        "data/oncampuscrime101112_cleaned.csv")
    college_instance = handlers.college_details(dataframe, university_name,
                                                branch_name)
    college_obj = coll.College(college_instance, crimes_obj)
    crime_per_student_without_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj)  # Question 1
    crime_per_student_with_average = handlers.all_crimes_per_student_over_years(
        college_obj, crimes_obj, average=True)  # Question 2
    crimes_per_student_by_category = handlers.average_crimes_per_student_by_category(
        dataframe, 'State', crimes_obj)  # Question 3
    pltparam = plotting.pltParam()
    answers_obj = plots.Answers(crimes_obj, college_obj, pltparam,
                                crime_per_student_without_average,
                                crime_per_student_with_average,
                                crimes_per_student_by_category)

    d = handlers.average_crimes_per_student_by_category(dataframe,
                                                        'State',
                                                        crimes_obj,
                                                        overall_average=True)

    answers_obj.simpleBarChart(d, "MA")