def create_gender_linegraph(all_students, years, title, export_path,medium=None): boys = {} girls = {} for year in years: boys[year] = filter_all(all_students[year], gender='M', medium = medium) girls[year] = filter_all(all_students[year], gender='F', medium = medium) gender_means = get_means([boys, girls], years) export_path = os.path.join(export_path, title) make_linegraph(gender_means, years, title, export_path, categories=["Baieti", "Fete"])
def create_medium_linegraph(all_students, years, title, export_path, gender=None): rural = {} urban = {} for year in years: urban[year] = filter_all(all_students[year], medium='urban', gender=gender) rural[year] = filter_all(all_students[year], medium='rural', gender=gender) medium_means = get_means([rural, urban], years) export_path = os.path.join(export_path, title) make_linegraph(medium_means, years, title , export_path, categories=["Rural", "Urban"])
def create_specialization_linegraph(all_students, years, title, export_path, first_spec, second_spec, medium=None, gender=None): first = {} second = {} for year in years: temp = filter_all(all_students[year], medium=medium, gender=gender) first[year] = filter_all(temp, specialisation=first_spec) second[year] = filter_all(temp, specialisation=second_spec) medium_means = get_means([first, second], years) export_path = os.path.join(export_path, title) make_linegraph(medium_means, years, title, export_path, categories=[first_spec, second_spec])
def specialisation_comparison_graph(all_students, years, title, specialisation_1, specialisation_2, specialisation_3, export_path, gender=None, medium=None): spec_1 = {} spec_2 = {} spec_3 = {} for year in years: spec_1[year] = filter_all(all_students[year], specialisation = specialisation_1, gender=gender, medium=medium) spec_2[year] = filter_all(all_students[year], specialisation = specialisation_2, gender=gender, medium=medium) spec_3[year] = filter_all(all_students[year], specialisation = specialisation_3, gender=gender, medium=medium) all_specs_means = get_means([spec_1, spec_2, spec_3], years) limits = min_max_mean([spec_1, spec_2, spec_3]) export_path = os.path.join(export_path, title) make_linegraph(all_specs_means, years, title, export_path, limits=limits, categories=[specialisation_1, specialisation_2, specialisation_3])
def make_gender_pizzachart(all_students, specialization, title, export_path, medium=None, region=None, locality=None, highschool=None, class_name=None): all_students = filter_all(all_students, specialisation=specialization, medium=medium, highschool=highschool, locality=locality, class_name=class_name) title = title + specialization boys,girls = get_gender_distribution(all_students) labels = 'Boys', 'Girls' numbers = [boys, girls] colors = ['blue', 'red'] make_pizzachart(numbers, labels, title, export_path=os.path.join(export_path, title))
def save_boxplots(students, title, medium): current_export_path = os.path.join(export_path, "boxplots") current_export_path = os.path.join(current_export_path, medium) if os.path.exists(current_export_path) == False: os.mkdir(current_export_path) current_export_path = os.path.join(current_export_path, title) mate_info_boys = filter_all(students, specialisation="matematica-informatica", gender="M") filo_boys = filter_all(students, specialisation="filologie", gender="M") stiinte_boys = filter_all(students, specialisation="stiinte ale naturii", gender="M") mate_info_girls = filter_all(students, specialisation="matematica-informatica", gender="F") filo_girls = filter_all(students, specialisation="filologie", gender="F") stiinte_girls = filter_all(students, specialisation="stiinte ale naturii", gender="F") grades = return_grades_as_array([ mate_info_boys, mate_info_girls, filo_boys, filo_girls, stiinte_boys, stiinte_girls ]) make_boxplot(grades, current_export_path, ["MATE-INFO", "FILO", "STIINTE"], title=title, medium=medium)
def create_distribution_json(students, year=None): plots_path = os.path.join(dirpath, r"jsons") distrib_path = os.path.join(plots_path, r"Distributions") if os.path.exists(distrib_path) == False: os.mkdir(distrib_path) make_distribution_json(students, year, "Toate Specializarile", distrib_path) for cr_spec in [ "matematica-informatica", "filologie", "stiinte ale naturii" ]: cr_students = filter_all(students, specialisation=cr_spec) make_distribution_json(students, year, cr_spec, distrib_path)
def get_county_means(filename_students): means = [] counties_used = [] all_students = initialize_students(filename_students, input_csv_units) count_noregion = 0 for current_student in all_students: if current_student.highschool.region not in counties_used: student_countyx = filter_all( all_students, region=current_student.highschool.region) counties_used.append(current_student.highschool.region) grades = returngrades(student_countyx) means.append(sum(grades) / len(grades)) if (current_student.highschool.name == "?"): count_noregion = count_noregion + 1 #the code of the institution cannot be found print(count_noregion) counties_used.sort() data = {'Judet': counties_used, 'Medie bac': means} df = pd.DataFrame(data) df.sort_values(by=['Judet']) return df
def make_third_option_pizzachart(all_students, specialization, title, export_path, medium=None, gender=None, region=None, locality=None, highschool=None, class_name=None): subjects_name = load_subjects() title = title + specialization dimension = len(subjects_name) indexes = [] subjects_distribution = np.zeros(dimension) all_students = filter_all(all_students, specialisation=specialization, medium=medium, gender=gender, highschool=highschool, locality=locality, class_name=class_name) for student in all_students: subjects_distribution[subjects_name.index(student.subject3)] += 1 for i in range(dimension): if subjects_distribution[i] == 0: indexes.append(i) subjects_distribution = np.delete(subjects_distribution, indexes) count = 0 for i in range(len(indexes)): subjects_name.pop(indexes[i] - count) count += 1 make_pizzachart(subjects_distribution, subjects_name, title, export_path=os.path.join(export_path, title))
def create_barchart_percentage_js(all_students, current_export_path_js, year): # ------procent promovabilitate general fete-baieti-------- current_export_path_1_js = os.path.join(current_export_path_js, "Fete-Baieti") if (os.path.exists(current_export_path_1_js) == False): os.mkdir(current_export_path_1_js) current_export_path_1_js = os.path.join(current_export_path_1_js, str(year)) all_students_passed = filter_all(all_students, passed="Promovat") all_boys = filter_all(all_students, gender="M") all_girls = filter_all(all_students, gender="F") all_boys_passed = filter_all(all_students_passed, gender="M") all_girls_passed = filter_all(all_students_passed, gender="F") students_list = [[len(all_boys)], [len(all_girls)]] students_list_passed = [[len(all_boys_passed)], [len(all_girls_passed)]] name_list_general = [["Baieti"], ["Fete"]] name_list_particular = ["Total"] make_barchart_percentage_js( all_categories=students_list, all_categories_good=students_list_passed, categories_general_names=name_list_general, categories_particular_names=name_list_particular, title=("Procentaj promovabilitate Fete - Baieti " + str(year)), current_export_path=current_export_path_1_js) # ------procent promovabilitate toate profilele baieti-fete-------- current_export_path_2_js = os.path.join( current_export_path_js, "Fete-Baieti mate-info, filo si stiinte") if (os.path.exists(current_export_path_2_js) == False): os.mkdir(current_export_path_2_js) current_export_path2_js = os.path.join(current_export_path_2_js, str(year)) boys_filo = filter_all(all_students, gender="M", specialisation="filologie") boys_filo_passed = filter_all(boys_filo, passed="Promovat") girls_filo = filter_all(all_students, gender="F", specialisation="filologie") girls_filo_passed = filter_all(girls_filo, passed="Promovat") boys_mate_info = filter_all(all_students, gender="M", specialisation="matematica-informatica") boys_mate_info_passed = filter_all(boys_mate_info, passed="Promovat") girls_mate_info = filter_all(all_students, gender="F", specialisation="matematica-informatica") girls_mate_info_passed = filter_all(girls_mate_info, passed="Promovat") boys_stiinte = filter_all(all_students, gender="M", specialisation="stiinte ale naturii") boys_stiinte_passed = filter_all(boys_stiinte, passed="Promovat") girls_stiinte = filter_all(all_students, gender="F", specialisation="stiinte ale naturii") girls_stiinte_passed = filter_all(girls_stiinte, passed="Promovat") boys_other = filter_all(all_students, gender="M", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) boys_other_passed = filter_all(boys_other, passed="Promovat") girls_other = filter_all(all_students, gender="F", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) girls_other_passed = filter_all(girls_other, passed="Promovat") boys_list = [ len(boys_filo), len(boys_mate_info), len(boys_stiinte), len(boys_other) ] girls_list = [ len(girls_filo), len(girls_mate_info), len(girls_stiinte), len(girls_other) ] students_list = [boys_list, girls_list] boys_list_passed = [ len(boys_filo_passed), len(boys_mate_info_passed), len(boys_stiinte_passed), len(boys_other_passed) ] girls_list_passed = [ len(girls_filo_passed), len(girls_mate_info_passed), len(girls_stiinte_passed), len(girls_other_passed) ] students_list_passed = [boys_list_passed, girls_list_passed] name_list_general = [["Baieti"], ["Fete"]] name_list_particular = ["Filo", "Mate-info", "Stiinte", "Other"] make_barchart_percentage_js( all_categories=students_list, all_categories_good=students_list_passed, categories_general_names=name_list_general, categories_particular_names=name_list_particular, title= ("Procentaj promovabilitate Fete - Baieti \nmate-info, filologie, stiinte ale naturii si restul " + str(year)), current_export_path=current_export_path2_js) # ------mate-info alegere sub3------------- current_export_path_4_js = os.path.join(current_export_path_js, "Alegere subiect mate-info") if (os.path.exists(current_export_path_4_js) == False): os.mkdir(current_export_path_4_js) current_export_path_4_js = os.path.join(current_export_path_4_js, str(year)) all_students_mate_info = filter_all( all_students, specialisation="matematica-informatica") all_students_informatica = filter_all(all_students_mate_info, subject3="informatica mi c/c++") all_students_biologie = filter_all(all_students_mate_info, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_mate_info, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_mate_info, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_mate_info, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_mate_info, subject3="fizica teo") students_list = [ all_students_informatica, all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) name_list = [ "Informatica", "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3_js( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III matematica-informatica " + str(year)), current_export_path=current_export_path_4_js) # ------Stiinte ale naturii alegere sub 3------ current_export_path_6_js = os.path.join( current_export_path_js, "Alegere subiect stiinte ale naturii") if (os.path.exists(current_export_path_6_js) == False): os.mkdir(current_export_path_6_js) current_export_path_6_js = os.path.join(current_export_path_6_js, str(year)) all_students_mate_info = filter_all(all_students, specialisation="stiinte ale naturii") all_students_informatica = filter_all(all_students_mate_info, subject3="informatica sn c/c++") all_students_biologie = filter_all(all_students_mate_info, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_mate_info, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_mate_info, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_mate_info, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_mate_info, subject3="fizica teo") students_list = [ all_students_biologie, all_students_anatomie, all_students_informatica, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) name_list = [ "Biologie", "Anatomie", "Informatica", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3_js( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III stiinte ale naturii " + str(year)), current_export_path=current_export_path_6_js) # ---------Filologie alegere sub3----------- current_export_path_5_js = os.path.join(current_export_path_js, "Alegere subiect filologie") if (os.path.exists(current_export_path_5_js) == False): os.mkdir(current_export_path_5_js) current_export_path_5_js = os.path.join(current_export_path_5_js, str(year)) all_students_filologie = filter_all(all_students, specialisation="filologie") all_students_filosofie = filter_all(all_students_filologie, subject3="filosofie") all_students_logica = filter_all( all_students_filologie, subject3="logica, argumentare si comunicare") all_students_sociologie = filter_all(all_students_filologie, subject3="sociologie") all_students_geografie = filter_all(all_students_filologie, subject3="geografie") all_students_psihologie = filter_all(all_students_filologie, subject3="psihologie") all_students_economie = filter_all(all_students_filologie, subject3="economie") students_list = [ all_students_filosofie, all_students_logica, all_students_sociologie, all_students_geografie, all_students_psihologie, all_students_economie ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) name_list = [ "Filosofie", "Logica", "Sociologie", "Geografie", "Psihologie", "Economie" ] make_barchart_percentage_subject3_js( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III filologie " + str(year)), current_export_path=current_export_path_5_js) # ------Profil tehnic alegere sub 3------------------------- current_export_path_7_js = os.path.join(current_export_path_js, "Alegere subiect profil Tehnic") if (os.path.exists(current_export_path_7_js) == False): os.mkdir(current_export_path_7_js) current_export_path_7_js = os.path.join(current_export_path_7_js, str(year)) all_students_tehnic = filter_all(all_students, profile="tehnic") # all_students_informatica = filter_all(all_students_mate_info, subject3 = "informatica mi c/c++") all_students_biologie = filter_all(all_students_tehnic, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_tehnic, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_tehnic, subject3="chimie organica teh nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_tehnic, subject3="chimie anorganica teh nivel i/ii") all_students_fizica = filter_all(all_students_tehnic, subject3="fizica teh") students_list = [ all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) name_list = [ "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3_js( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III Profil Tehnic " + str(year)), current_export_path=current_export_path_7_js) # ------profil Resurse Naturale alegere sub3---------------- current_export_path_8_js = os.path.join( current_export_path_js, "Alegere subiect profil Resurse Naturale") if (os.path.exists(current_export_path_8_js) == False): os.mkdir(current_export_path_8_js) current_export_path_8_js = os.path.join(current_export_path_8_js, str(year)) all_students_resurse = filter_all( all_students, profile="resurse naturale si protectia mediului") all_categories = {} for i in all_students_resurse: all_categories[i.subject3] = "found" # all_students_informatica = filter_all(all_students_mate_info, subject3 = "informatica mi c/c++") all_students_biologie = filter_all(all_students_resurse, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_resurse, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_resurse, subject3="chimie organica teh nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_resurse, subject3="chimie anorganica teh nivel i/ii") all_students_fizica = filter_all(all_students_resurse, subject3="fizica teh") students_list = [ all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) name_list = [ "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3_js( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III Profil Resurse Naturale " + str(year)), current_export_path=current_export_path_8_js) # ------nota romana mate-info - stiinte ale naturii--------- mate_info = filter_all(all_students, specialisation="matematica-informatica") stiinte = filter_all(all_students, specialisation="stiinte ale naturii") grade_mate_info_romana = 0 grade_stiinte_romana = 0 for element in mate_info: grade_mate_info_romana += element.subject1_grade_final for element in stiinte: grade_stiinte_romana += element.subject1_grade_final current_export_path_3_js = os.path.join(current_export_path_js, "Romana mate-info si stiinte") if (os.path.exists(current_export_path_3_js) == False): os.mkdir(current_export_path_3_js) current_export_path_3_js = os.path.join(current_export_path_3_js, str(year)) grade_mate_info_romana = float(grade_mate_info_romana) / float( len(mate_info)) grade_stiinte_romana = float(grade_stiinte_romana) / float(len(stiinte)) grades = [[grade_mate_info_romana], [grade_stiinte_romana]] name_list = ["Mate-info", "Stiinte"] make_barchart_values_js(grades, ["mate-info", "stiinte"], ["Nota romana"], "Note romana", current_export_path_3_js) # -----Medie bacalaureat urban-rural------------------------ urban_students = filter_all(all_students=all_students, medium="urban") rural_students = filter_all(all_students=all_students, medium="rural") grade_urban = 0 grade_rural = 0 for elem in urban_students: grade_urban += elem.final_grade for elem in rural_students: grade_rural += elem.final_grade grade_urban /= len(urban_students) grade_rural /= len(rural_students) current_export_path_13_js = os.path.join(current_export_path_js, "Medie Bacalaureat Urban-Rural") if (os.path.exists(current_export_path_13_js) == False): os.mkdir(current_export_path_13_js) current_export_path_13_js = os.path.join(current_export_path_13_js, str(year)) grades = [[grade_urban], [grade_rural]] make_barchart_values_js(grades, ["Urban", "Rural"], ["Medie Bacalaureat"], "Medie Bacalaureat", current_export_path_13_js) # ----Medie bacalaureat urban-rural fete-baieti--------- current_export_path_14_js = os.path.join( current_export_path_js, "Medie Bacalaureat Urban-Rural Fete-Baieti") if (os.path.exists(current_export_path_14_js) == False): os.mkdir(current_export_path_14_js) current_export_path_14_js = os.path.join(current_export_path_14_js, str(year)) urban_students = filter_all(all_students=all_students, medium="urban") rural_students = filter_all(all_students=all_students, medium="rural") urban_girls = filter_all(all_students=urban_students, gender="F") urban_boys = filter_all(all_students=urban_students, gender="M") rural_girls = filter_all(all_students=rural_students, gender="F") rural_boys = filter_all(all_students=rural_students, gender="M") grade_urban_girls = 0 grade_rural_girls = 0 grade_urban_boys = 0 grade_rural_boys = 0 for elem in urban_girls: grade_urban_girls += elem.final_grade for elem in rural_girls: grade_rural_girls += elem.final_grade for elem in urban_boys: grade_urban_boys += elem.final_grade for elem in rural_boys: grade_rural_boys += elem.final_grade grade_urban_girls /= len(urban_girls) grade_rural_girls /= len(rural_girls) grade_urban_boys /= len(urban_boys) grade_rural_boys /= len(rural_boys) grades = [[grade_urban_girls, grade_urban_boys], [grade_rural_girls, grade_rural_boys]] make_barchart_values_js( grades, ["Urban", "Rural"], ["Medie Bacalaureat Fete", "Medie Bacalaureat Baieti"], "Medie Bacalaureat Urban-Rural Fete-Baieti", current_export_path_14_js) # -------Medie bacalaureat pe profile----------------------- current_export_path_15_js = os.path.join(current_export_path_js, "Medie Bacalaureat pe Profile") if (os.path.exists(current_export_path_15_js) == False): os.mkdir(current_export_path_15_js) current_export_path_15_js = os.path.join(current_export_path_15_js, str(year)) mate_info_students = filter_all(all_students=all_students, specialisation="matematica-informatica") stiinte_students = filter_all(all_students=all_students, specialisation="stiinte ale naturii") filo_studentts = filter_all(all_students=all_students, specialisation="filologie") grade_mate_info = 0 grade_filo = 0 grade_stiinte = 0 for elem in mate_info_students: grade_mate_info += elem.final_grade for elem in filo_studentts: grade_filo += elem.final_grade for elem in stiinte_students: grade_stiinte += elem.final_grade grade_filo /= len(filo_studentts) grade_mate_info /= len(mate_info_students) grade_stiinte /= len(stiinte_students) grades = [[grade_filo], [grade_mate_info], [grade_stiinte]] make_barchart_values_js( grades, ["Filologie", "Matematica-Informatica", "Stiinte ale Naturii"], ["Medie Bacalaureat"], "Medie Bacalaureat pe Profile", current_export_path_15_js) # -----procentaj promovabilitate urban-rural---------------- current_export_path_9_js = os.path.join( current_export_path_js, "Procentaj Promovabilitate urban-rural") if (os.path.exists(current_export_path_9_js) == False): os.mkdir(current_export_path_9_js) current_export_path_9_js = os.path.join(current_export_path_9_js, str(year)) all_students_passed = filter_all(all_students, passed="Promovat") all_students_urban = filter_all(all_students=all_students, medium="urban") all_students_urban_passed = filter_all(all_students=all_students_passed, medium="urban") all_students_rural = filter_all(all_students=all_students, medium="rural") all_students_rural_passed = filter_all(all_students=all_students_passed, medium="rural") categories_general_names = [["Urban"], ["Rural"]] categories_particular_names = ["Total"] all_students_list = [[len(all_students_urban)], [len(all_students_rural)]] all_students_passed_list = [[len(all_students_urban_passed)], [len(all_students_rural_passed)]] make_barchart_percentage_js( all_categories=all_students_list, all_categories_good=all_students_passed_list, categories_general_names=categories_general_names, categories_particular_names=categories_particular_names, title=("Procentaj Promovabilitate urban-rural" + str(year)), current_export_path=current_export_path_9_js) # make_barchart_percentage(all_categories = all_students_list, all_categories_good = all_students_passed_list, categories_names = name_list, title = ("Procentaj Promovabilitate urban-rural " + str(year)), current_export_path = current_export_path_9_js, colors = ['#F4DADA', '#BEEBE9']) # -----procentaj promovabilitate fete-baieti urban-rural------------ current_export_path_10_js = os.path.join( current_export_path_js, "Procentaj Promovabilitate fete-baieti urban-rural") if (os.path.exists(current_export_path_10_js) == False): os.mkdir(current_export_path_10_js) current_export_path_10_js = os.path.join(current_export_path_10_js, str(year)) all_students_passed = filter_all(all_students, passed="Promovat") all_students_urban = filter_all(all_students=all_students, medium="urban") all_students_urban_boys = filter_all(all_students=all_students_urban, gender="M") all_students_urban_girls = filter_all(all_students=all_students_urban, gender="F") all_students_urban_passed = filter_all(all_students=all_students_passed, medium="urban") all_students_urban_boys_passed = filter_all( all_students=all_students_urban_passed, gender="M") all_students_urban_girls_passed = filter_all( all_students=all_students_urban_passed, gender="F") all_students_rural = filter_all(all_students=all_students, medium="rural") all_students_rural_boys = filter_all(all_students=all_students_rural, gender="M") all_students_rural_girls = filter_all(all_students=all_students_rural, gender="F") all_students_rural_passed = filter_all(all_students=all_students_passed, medium="rural") all_students_rural_boys_passed = filter_all( all_students=all_students_rural_passed, gender="M") all_students_rural_girls_passed = filter_all( all_students=all_students_rural_passed, gender="F") name_list = ["Baieti-Urban", "Fete-Urban", "Baieti-Rural", "Fete-Rural"] all_students_list = [[ len(all_students_urban_boys), len(all_students_rural_boys) ], [len(all_students_urban_girls), len(all_students_rural_girls)]] all_students_passed_list = [[ len(all_students_urban_boys_passed), len(all_students_rural_boys_passed) ], [ len(all_students_urban_girls_passed), len(all_students_rural_girls_passed) ]] categories_general_names = [["Baieti"], ["Fete"]] categories_particular_names = ["Urban", "Rural"] make_barchart_percentage_js( all_categories=all_students_list, all_categories_good=all_students_passed_list, categories_general_names=categories_general_names, categories_particular_names=categories_particular_names, title=("Procentaj Promovabilitate urban-rural" + str(year)), current_export_path=current_export_path_10_js) # make_barchart_percentage(all_categories = all_students_list, all_categories_good = all_students_passed_list, categories_names = name_list, title = ("Procentaj Promovabilitate fete-baieti urban-rural " + str(year)), current_export_path = current_export_path_10_js, colors = ['#F4DADA', '#BEEBE9']) # -------procentaj alegere profil in functie de mediu de viata----------------- current_export_path_11_js = os.path.join( current_export_path_js, "Procentaj alegere profil in functie de mediu de viata") if (os.path.exists(current_export_path_11_js) == False): os.mkdir(current_export_path_11_js) current_export_path_11_js = os.path.join(current_export_path_11_js, str(year)) urban_filo = filter_all(all_students, medium="urban", specialisation="filologie") rural_filo = filter_all(all_students, medium="rural", specialisation="filologie") urban_mate_info = filter_all(all_students, medium="urban", specialisation="matematica-informatica") rural_mate_info = filter_all(all_students, medium="rural", specialisation="matematica-informatica") urban_stiinte = filter_all(all_students, medium="urban", specialisation="stiinte ale naturii") rural_stiinte = filter_all(all_students, medium="rural", specialisation="stiinte ale naturii") urban_other = filter_all(all_students, medium="urban", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) rural_other = filter_all(all_students, medium="rural", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) urban_stats = [ len(urban_filo), len(urban_mate_info), len(urban_stiinte), len(urban_other) ] rural_stats = [ len(rural_filo), len(rural_mate_info), len(rural_stiinte), len(rural_other) ] vertical_names = ["Urban", "Rural"] horizontal_names = ["Filo", "Mate_info", "Stiinte", "Other"] all_categories = [urban_stats, rural_stats] make_stacked_barchart_js( all_categories=all_categories, vertical_names=vertical_names, horizontal_names=horizontal_names, title=("Procentaj alegere profil in functie de sex" + str(year)), current_export_path=current_export_path_11_js) # -----procentaj alegere profil in functie de sex--------------------------- current_export_path_12_js = os.path.join( current_export_path_js, "Procentaj alegere profil in functie de sex") if (os.path.exists(current_export_path_12_js) == False): os.mkdir(current_export_path_12_js) current_export_path_12_js = os.path.join(current_export_path_12_js, str(year)) boys_filo = filter_all(all_students, gender="M", specialisation="filologie") girls_filo = filter_all(all_students, gender="F", specialisation="filologie") boys_mate_info = filter_all(all_students, gender="M", specialisation="matematica-informatica") girls_mate_info = filter_all(all_students, gender="F", specialisation="matematica-informatica") boys_stiinte = filter_all(all_students, gender="M", specialisation="stiinte ale naturii") girls_stiinte = filter_all(all_students, gender="F", specialisation="stiinte ale naturii") boys_other = filter_all(all_students, gender="M", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) girls_other = filter_all(all_students, gender="F", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) urban_stats = [ len(boys_filo), len(boys_mate_info), len(boys_stiinte), len(boys_other) ] rural_stats = [ len(girls_filo), len(girls_mate_info), len(girls_stiinte), len(girls_other) ] vertical_names = ["Baieti", "Fete"] horizontal_names = ["Filo", "Mate_info", "Stiinte", "Other"] all_categories = [urban_stats, rural_stats] make_stacked_barchart_js( all_categories=all_categories, vertical_names=vertical_names, horizontal_names=horizontal_names, title=("Procentaj alegere profil in functie de sex" + str(year)), current_export_path=current_export_path_12_js)
if __name__ == "__main__": year = [2015, 2016, 2017, 2019] all_files = glob.glob(os.path.join(input_csv_students, "*.csv")) current_export_path = os.path.join(dirpath, 'plots') # make line graph with average of the public vs private institutions all_private = [] all_public = [] current_export_path = os.path.join(current_export_path, 'publicPrivate') i = 0 for filename_students in all_files: if filename_students.endswith(".csv"): all_students = initialize_students(filename_students, input_csv_units) print(filename_students) private_students = filter_all(all_students, property="Privata") public_students = filter_all( all_students, property='Publica de interes national Si local') i = i + 1 all_private.append( sum(returngrades(private_students)) / len(returngrades(private_students))) all_public.append( sum(returngrades(public_students)) / len(returngrades(public_students))) firstplot = plt.plot(year, all_private, marker='o', markerfacecolor='blue', markersize=12,
def create_barchart_percentage(all_students, current_export_path, year): #------procent promovabilitate general fete-baieti-------- current_export_path_1 = os.path.join(current_export_path, "Fete-Baieti") if (os.path.exists(current_export_path_1) == False): os.mkdir(current_export_path_1) current_export_path_1 = os.path.join(current_export_path_1, str(year)) all_students_passed = filter_all(all_students, passed="Promovat") all_boys = filter_all(all_students, gender="M") all_girls = filter_all(all_students, gender="F") all_boys_passed = filter_all(all_students_passed, gender="M") all_girls_passed = filter_all(all_students_passed, gender="F") students_list = [all_boys, all_girls] students_list_passed = [all_boys_passed, all_girls_passed] name_list = ["Baieti", "Fete"] colors = ['#BEEBE9', '#F4DADA'] make_barchart_percentage( all_categories=students_list, all_categories_good=students_list_passed, categories_names=name_list, title=("Procentaj promovabilitate Fete - Baieti " + str(year)), current_export_path=current_export_path_1, colors=colors) #------procent promovabilitate toate profilele baieti-fete-------- current_export_path_2 = os.path.join( current_export_path, "Fete-Baieti mate-info, filo si stiinte") if (os.path.exists(current_export_path_2) == False): os.mkdir(current_export_path_2) current_export_path2 = os.path.join(current_export_path_2, str(year)) boys_filo = filter_all(all_students, gender="M", specialisation="filologie") girls_filo = filter_all(all_students, gender="F", specialisation="filologie") boys_mate_info = filter_all(all_students, gender="M", specialisation="matematica-informatica") girls_mate_info = filter_all(all_students, gender="F", specialisation="matematica-informatica") boys_stiinte = filter_all(all_students, gender="M", specialisation="stiinte ale naturii") girls_stiinte = filter_all(all_students, gender="F", specialisation="stiinte ale naturii") boys_other = filter_all(all_students, gender="M", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) girls_other = filter_all(all_students, gender="F", specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii" ]) colors = [ '#BEEBE9', '#F4DADA', '#BEEBE9', '#F4DADA', '#BEEBE9', '#F4DADA', '#BEEBE9', '#F4DADA' ] students_list = [ boys_other, girls_other, boys_filo, girls_filo, boys_mate_info, girls_mate_info, boys_stiinte, girls_stiinte ] name_list = [ "Baitei other", "Fete other", "Baieti filologie", "Fete filologie", "Baieti mate-info", "Fete mate-info", "Baieti stiinte", "Fete stiinte" ] students_list_passed = [] for crt_student_list in students_list: students_list_passed.append( filter_all(crt_student_list, passed="Promovat")) make_barchart_percentage( all_categories=students_list, all_categories_good=students_list_passed, categories_names=name_list, title= ("Procentaj promovabilitate Fete - Baieti \nmate-info, filologie, stiinte ale naturii si restul " + str(year)), current_export_path=current_export_path2, colors=colors) #------mate-info alegere sub3------------- current_export_path_4 = os.path.join(current_export_path, "Alegere subiect mate-info") if (os.path.exists(current_export_path_4) == False): os.mkdir(current_export_path_4) current_export_path_4 = os.path.join(current_export_path_4, str(year)) all_students_mate_info = filter_all( all_students, specialisation="matematica-informatica") all_students_informatica = filter_all(all_students_mate_info, subject3="informatica mi c/c++") all_students_biologie = filter_all(all_students_mate_info, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_mate_info, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_mate_info, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_mate_info, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_mate_info, subject3="fizica teo") students_list = [ all_students_informatica, all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) colors = ['#BEEBE9', '#F4DADA', '#ffb6b9', '#f6eec7', '#B3C7BA', '#B28B90'] name_list = [ "Informatica", "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III matematica-informatica " + str(year)), current_export_path=current_export_path_4, colors=colors) #------Stiinte ale naturii alegere sub 3------ current_export_path_6 = os.path.join( current_export_path, "Alegere subiect stiinte ale naturii") if (os.path.exists(current_export_path_6) == False): os.mkdir(current_export_path_6) current_export_path_6 = os.path.join(current_export_path_6, str(year)) all_students_mate_info = filter_all(all_students, specialisation="stiinte ale naturii") all_students_informatica = filter_all(all_students_mate_info, subject3="informatica sn c/c++") all_students_biologie = filter_all(all_students_mate_info, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_mate_info, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_mate_info, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_mate_info, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_mate_info, subject3="fizica teo") students_list = [ all_students_biologie, all_students_anatomie, all_students_informatica, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) colors = ['#BEEBE9', '#F4DADA', '#ffb6b9', '#f6eec7', '#658763', '#B28B90'] name_list = [ "Biologie", "Anatomie", "Informatica", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III stiinte ale naturii " + str(year)), current_export_path=current_export_path_6, colors=colors) #---------Filologie alegere sub3----------- current_export_path_5 = os.path.join(current_export_path, "Alegere subiect filologie") if (os.path.exists(current_export_path_5) == False): os.mkdir(current_export_path_5) current_export_path_5 = os.path.join(current_export_path_5, str(year)) all_students_filologie = filter_all(all_students, specialisation="filologie") all_students_filosofie = filter_all(all_students_filologie, subject3="filosofie") all_students_logica = filter_all( all_students_filologie, subject3="logica, argumentare si comunicare") all_students_sociologie = filter_all(all_students_filologie, subject3="sociologie") all_students_geografie = filter_all(all_students_filologie, subject3="geografie") all_students_psihologie = filter_all(all_students_filologie, subject3="psihologie") all_students_economie = filter_all(all_students_filologie, subject3="economie") students_list = [ all_students_filosofie, all_students_logica, all_students_sociologie, all_students_geografie, all_students_psihologie, all_students_economie ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) colors = ['#BEEBE9', '#F4DADA', '#ffb6b9', '#f6eec7', '#B3C7BA', '#658763'] name_list = [ "Filosofie", "Logica", "Sociologie", "Geografie", "Psihologie", "Economie" ] make_barchart_percentage_subject3( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III filologie " + str(year)), current_export_path=current_export_path_5, colors=colors) #------Profil tehnic alegere sub 3------------------------- current_export_path_7 = os.path.join(current_export_path, "Alegere subiect profil Tehnic") if (os.path.exists(current_export_path_7) == False): os.mkdir(current_export_path_7) current_export_path_7 = os.path.join(current_export_path_7, str(year)) all_students_tehnic = filter_all(all_students, profile="tehnic") #all_students_informatica = filter_all(all_students_mate_info, subject3 = "informatica mi c/c++") all_students_biologie = filter_all(all_students_tehnic, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_tehnic, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_tehnic, subject3="chimie organica teh nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_tehnic, subject3="chimie anorganica teh nivel i/ii") all_students_fizica = filter_all(all_students_tehnic, subject3="fizica teh") students_list = [ all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) colors = ['#BEEBE9', '#F4DADA', '#ffb6b9', '#f6eec7', '#B28B90'] name_list = [ "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III Profil Tehnic " + str(year)), current_export_path=current_export_path_7, colors=colors) #------profil Resurse Naturale alegere sub3---------------- current_export_path_8 = os.path.join( current_export_path, "Alegere subiect profil Resurse Naturale") if (os.path.exists(current_export_path_8) == False): os.mkdir(current_export_path_8) current_export_path_8 = os.path.join(current_export_path_8, str(year)) all_students_resurse = filter_all( all_students, profile="resurse naturale si protectia mediului") all_categories = {} for i in all_students_resurse: all_categories[i.subject3] = "found" #all_students_informatica = filter_all(all_students_mate_info, subject3 = "informatica mi c/c++") all_students_biologie = filter_all(all_students_resurse, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_resurse, subject3="anatomie si fiziologie umana, genetica si ecologie umana") all_students_chimie_organica = filter_all( all_students_resurse, subject3="chimie organica teh nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_resurse, subject3="chimie anorganica teh nivel i/ii") all_students_fizica = filter_all(all_students_resurse, subject3="fizica teh") students_list = [ all_students_biologie, all_students_anatomie, all_students_chimie_organica, all_students_chimie_anorganica, all_students_fizica ] all_grades = [] for student_type in students_list: suma = 0 for student in student_type: suma += student.subject3_grade_final suma = float(suma) / float(len(student_type)) all_grades.append(suma) colors = ['#BEEBE9', '#F4DADA', '#ffb6b9', '#f6eec7', '#B28B90'] name_list = [ "Biologie", "Anatomie", "Chimie Organica", "Chimie Anorganica", "Fizica" ] make_barchart_percentage_subject3( all_students=students_list, all_grades=all_grades, categories_names=name_list, title=("Procentaj alegere subiectul III Profil Resurse Naturale" + str(year)), current_export_path=current_export_path_8, colors=colors) #------nota romana mate-info - stiinte ale naturii--------- mate_info = filter_all(all_students, specialisation="matematica-informatica") stiinte = filter_all(all_students, specialisation="stiinte ale naturii") grade_mate_info_romana = 0 grade_stiinte_romana = 0 for element in mate_info: grade_mate_info_romana += element.subject1_grade_final for element in stiinte: grade_stiinte_romana += element.subject1_grade_final current_export_path_3 = os.path.join(current_export_path, "Romana mate-info si stiinte") if (os.path.exists(current_export_path_3) == False): os.mkdir(current_export_path_3) current_export_path_3 = os.path.join(current_export_path_3, str(year)) grade_mate_info_romana = float(grade_mate_info_romana) / float( len(mate_info)) grade_stiinte_romana = float(grade_stiinte_romana) / float(len(stiinte)) grades = [grade_mate_info_romana, grade_stiinte_romana] make_barchart_values(grades, ["mate-info", "stiinte"], "Note romana", current_export_path_3, ['#BEEBE9', '#F4DADA'])
def create_line_graph_js(all_students, current_export_path_js, years): noStudents = 0 general_export_path_js = current_export_path_js #--MEDII---------------------------- current_export_path_js = os.path.join(general_export_path_js, "Dupa Medie") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) #-----MEDIE ANUALA--------- all_averages = [] for year in years: average = 0 noStudents = 0 for elem in all_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei totale", current_export_path=current_export_path_js, years=years) #-----MEDIE PE PROFILE----- #-----1.MATE INFO---------- crt_students = {} for year in years: crt_students[year] = filter_all( all_students=all_students[year], specialisation="matematica-informatica") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei la mate-info", current_export_path=current_export_path_js, years=years) #-----2.FILO------------- crt_students = {} for year in years: crt_students[year] = filter_all(all_students=all_students[year], specialisation="filologie") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei la filologie", current_export_path=current_export_path_js, years=years) #-----3.STIINTE ALE NATURII----- crt_students = {} for year in years: crt_students[year] = filter_all(all_students=all_students[year], specialisation="stiinte ale naturii") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei la stiinte ale naturii", current_export_path=current_export_path_js, years=years) #-----4.STIINTE SOCIALE------- crt_students = {} for year in years: crt_students[year] = filter_all(all_students=all_students[year], specialisation="stiinte sociale") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei la stiinte ale sociale", current_export_path=current_export_path_js, years=years) #-----5.PROFILE TEHNICE/TEHNOLOGICE----- crt_students = {} for year in years: crt_students[year] = filter_all(all_students[year], specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii", "stiinte sociale" ]) all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js( all_categories=all_averages, OYName="Medie", title="Evolutia mediei la filiera tehnologica si tehnica", current_export_path=current_export_path_js, years=years) #----MEDII PE URBAN------ crt_students = {} for year in years: crt_students[year] = filter_all(all_students=all_students[year], medium="urban") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei in zona urbana", current_export_path=current_export_path_js, years=years) #-----MEDII PE RURAL---- crt_students = {} for year in years: crt_students[year] = filter_all(all_students=all_students[year], medium="rural") all_averages = [] for year in years: average = 0 noStudents = 0 for elem in crt_students[year]: if elem.final_grade >= 1: average += elem.final_grade noStudents += 1 average /= noStudents all_averages.append(average) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia mediei in zona rurala", current_export_path=current_export_path_js, years=years) #-----PROCENTAJE PROMOVABILITATE----------------- current_export_path_js = os.path.join(general_export_path_js, "Dupa Procentaj Promovabilitate") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) #-----PROCENTAJ PE PROFILE----- #-----1.MATE INFO---------- all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], specialisation="matematica-informatica") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii la mate-info", current_export_path=current_export_path_js, years=years) #-----2.FILO------------- all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], specialisation="filologie") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii la filologie", current_export_path=current_export_path_js, years=years) #-----3.STIINTE ALE NATURII----- all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], specialisation="stiinte ale naturii") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js( all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii la stiinte ale naturii", current_export_path=current_export_path_js, years=years) #-----4.STIINTE SOCIALE------- all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], specialisation="stiinte sociale") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js( all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii la stiinte ale sociale", current_export_path=current_export_path_js, years=years) #-----5.PROCENTAJ TEHNICE/TEHNOLOGICE----- all_averages = [] for year in years: crt_students = filter_all(all_students[year], specialisation_list=[ "filologie", "matematica-informatica", "stiinte ale naturii", "stiinte sociale" ]) passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js( all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii la filiera tehnologica si tehnica", current_export_path=current_export_path_js, years=years) #----PROCENTAJ PE URBAN------ all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], medium="urban") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii in zona urbana", current_export_path=current_export_path_js, years=years) #-----PROCENTAJ PE RURAL---- all_averages = [] for year in years: crt_students = filter_all(all_students=all_students[year], medium="rural") passed_students = filter_all(all_students=crt_students, passed="Promovat") all_averages.append(len(passed_students) / len(crt_students) * 100) make_line_graph_js(all_categories=all_averages, OYName="Medie", title="Evolutia promovabilitatii in zona rurala", current_export_path=current_export_path_js, years=years) #--PROCENTAJ ALEGERE SUBIECTUL III partial_export_path_js = os.path.join(general_export_path_js, "Dupa Procentaj Alegere SIII") if (os.path.exists(partial_export_path_js) == False): os.mkdir(partial_export_path_js) #---1.MATE-INFO-------- current_export_path_js = os.path.join(partial_export_path_js, "Mate-Info") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) info = [] bio = [] anatomie = [] chimie_org = [] chimie_anorg = [] fizica = [] for year in years: all_students_mate_info = filter_all( all_students[year], specialisation="matematica-informatica") all_students_informatica = filter_all(all_students_mate_info, subject3="informatica mi c/c++") all_students_biologie = filter_all( all_students_mate_info, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_mate_info, subject3="anatomie si fiziologie umana, genetica si ecologie umana" ) all_students_chimie_organica = filter_all( all_students_mate_info, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_mate_info, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_mate_info, subject3="fizica teo") noStudents = len(all_students_mate_info) info.append(len(all_students_informatica) / noStudents * 100) bio.append(len(all_students_biologie) / noStudents * 100) anatomie.append(len(all_students_anatomie) / noStudents * 100) chimie_org.append(len(all_students_chimie_organica) / noStudents * 100) chimie_anorg.append( len(all_students_chimie_anorganica) / noStudents * 100) fizica.append(len(all_students_fizica) / noStudents * 100) make_line_graph_js(all_categories=info, OYName="Procent", title="Procentaj alegere informatica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=bio, OYName="Procent", title="Procentaj alegere biologie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=anatomie, OYName="Procent", title="Procentaj alegere anatomie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_org, OYName="Procent", title="Procentaj alegere chimie organica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_anorg, OYName="Procent", title="Procentaj alegere chimie anorganica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=fizica, OYName="Procent", title="Procentaj alegere fizica", current_export_path=current_export_path_js, years=years) #---2.STIINTE ALE NATURII--- current_export_path_js = os.path.join(partial_export_path_js, "Stiinte ale naturii") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) info = [] bio = [] anatomie = [] chimie_org = [] chimie_anorg = [] fizica = [] for year in years: all_students_stiinte = filter_all(all_students[year], specialisation="stiinte ale naturii") all_students_informatica = filter_all(all_students_stiinte, subject3="informatica sn c/c++") all_students_biologie = filter_all( all_students_stiinte, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_stiinte, subject3="anatomie si fiziologie umana, genetica si ecologie umana" ) all_students_chimie_organica = filter_all( all_students_stiinte, subject3="chimie organica teo nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_stiinte, subject3="chimie anorganica teo nivel i/ii") all_students_fizica = filter_all(all_students_stiinte, subject3="fizica teo") noStudents = len(all_students_stiinte) info.append(len(all_students_informatica) / noStudents * 100) bio.append(len(all_students_biologie) / noStudents * 100) anatomie.append(len(all_students_anatomie) / noStudents * 100) chimie_org.append(len(all_students_chimie_organica) / noStudents * 100) chimie_anorg.append( len(all_students_chimie_anorganica) / noStudents * 100) fizica.append(len(all_students_fizica) / noStudents * 100) make_line_graph_js(all_categories=info, OYName="Procent", title="Procentaj alegere informatica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=bio, OYName="Procent", title="Procentaj alegere biologie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=anatomie, OYName="Procent", title="Procentaj alegere anatomie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_org, OYName="Procent", title="Procentaj alegere chimie organica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_anorg, OYName="Procent", title="Procentaj alegere chimie anorganica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=fizica, OYName="Procent", title="Procentaj alegere fizica", current_export_path=current_export_path_js, years=years) #---3.FILOLOGIE------ current_export_path_js = os.path.join(partial_export_path_js, "Filologie") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) filosoife = [] logica = [] sociologie = [] geo = [] psiho = [] economie = [] for year in years: all_students_filologie = filter_all(all_students[year], specialisation="filologie") all_students_filosofie = filter_all(all_students_filologie, subject3="filosofie") all_students_logica = filter_all( all_students_filologie, subject3="logica, argumentare si comunicare") all_students_sociologie = filter_all(all_students_filologie, subject3="sociologie") all_students_geografie = filter_all(all_students_filologie, subject3="geografie") all_students_psihologie = filter_all(all_students_filologie, subject3="psihologie") all_students_economie = filter_all(all_students_filologie, subject3="economie") noStudents = len(all_students_filologie) filosoife.append(len(all_students_filosofie) / noStudents * 100) logica.append(len(all_students_logica) / noStudents * 100) geo.append(len(all_students_geografie) / noStudents * 100) psiho.append(len(all_students_psihologie) / noStudents * 100) economie.append(len(all_students_economie) / noStudents * 100) sociologie.append(len(all_students_sociologie) / noStudents * 100) make_line_graph_js(all_categories=filosoife, OYName="Procent", title="Procentaj alegere filosofie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=logica, OYName="Procent", title="Procentaj alegere logica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=sociologie, OYName="Procent", title="Procentaj alegere sociologie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=geo, OYName="Procent", title="Procentaj alegere geografie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=psiho, OYName="Procent", title="Procentaj alegere psiholohie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=sociologie, OYName="Procent", title="Procentaj alegere sociologie", current_export_path=current_export_path_js, years=years) #---4.Tehnic----- current_export_path_js = os.path.join(partial_export_path_js, "Tehnic") if (os.path.exists(current_export_path_js) == False): os.mkdir(current_export_path_js) bio = [] anatomie = [] chimie_org = [] chimie_anorg = [] fizica = [] for year in years: all_students_tehnic = filter_all(all_students[year], profile="tehnic") all_students_biologie = filter_all( all_students_tehnic, subject3="biologie vegetala si animala") all_students_anatomie = filter_all( all_students_tehnic, subject3="anatomie si fiziologie umana, genetica si ecologie umana" ) all_students_chimie_organica = filter_all( all_students_tehnic, subject3="chimie organica teh nivel i/ii") all_students_chimie_anorganica = filter_all( all_students_tehnic, subject3="chimie anorganica teh nivel i/ii") all_students_fizica = filter_all(all_students_tehnic, subject3="fizica teh") noStudents = len(all_students_tehnic) bio.append(len(all_students_biologie) / noStudents * 100) anatomie.append(len(all_students_anatomie) / noStudents * 100) chimie_org.append(len(all_students_chimie_organica) / noStudents * 100) chimie_anorg.append( len(all_students_chimie_anorganica) / noStudents * 100) fizica.append(len(all_students_fizica) / noStudents * 100) make_line_graph_js(all_categories=bio, OYName="Procent", title="Procentaj alegere biologie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=anatomie, OYName="Procent", title="Procentaj alegere anatomie", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_org, OYName="Procent", title="Procentaj alegere chimie organica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=chimie_anorg, OYName="Procent", title="Procentaj alegere chimie anorganica", current_export_path=current_export_path_js, years=years) make_line_graph_js(all_categories=fizica, OYName="Procent", title="Procentaj alegere fizica", current_export_path=current_export_path_js, years=years)
def create_map_json(filename_students, current_export_path): final_dict = { "meta": { "type": "MAP_CHART", "title": "Promovabilitatea pe judete", "number_precision": 2, "min_val": 0, "max_val": 100, "suffix": "%", "extra_formats": [{ "suffix": "elevi", "number_precision": 0 }, { "suffix": "", "number_precision": 2 }] }, "series": [] } temp_dict = {} # stores the mean and number of students for each county all_students = initialize_students(filename_students, input_csv_units) count_noregion = 0 for current_student in all_students: if current_student.highschool.region not in temp_dict: county = current_student.highschool.region student_countyx = filter_all(all_students, region=county) # calculate passing rate ofr this county(region) passed_students = filter_all(student_countyx, passed="Promovat") pass_rate = len(passed_students) / len(student_countyx) # calculate mean for this county grades = returngrades(student_countyx) mean = sum(grades) / len(grades) number = len(grades) temp_dict[str(county)] = (mean, number, pass_rate) if (current_student.highschool.name == "?"): count_noregion = count_noregion + 1 #the code of the institution cannot be found print(count_noregion) temp_dict = OrderedDict(sorted(temp_dict.items())) for (k, v) in temp_dict.items(): new_dict = {} new_dict["key"] = k new_dict["value"] = round(v[2] * 100, 3) # pass_rate for county k extra_1 = {"label": "Nr. elevi", "value": v[1]} extra_2 = { "label": "Media", "value": round(v[0], 2) # mean } extra = [extra_1, extra_2] new_dict["extra"] = extra final_dict["series"].append(new_dict) f = open(current_export_path + ".txt", "w+") jsonDict = json.dumps(final_dict) f.write(jsonDict)
year=year) if __name__ == "__main__": base_path = os.path.join(dirpath, r"data") students_years = {} # dict containing list of results for each year years = [] # available keys for the previous dict for year in range(2015, 2020): try: csv_path = os.path.join(base_path, "good_bac_" + str(year) + ".csv") all_students = initialize_students(csv_path) years.append(str( year)) # results for this year are stored in the dictionary students_years[str(year)] = all_students all_students = filter_all(all_students, grade=5) urban_students = filter_all(all_students, medium="urban") rural_students = filter_all(all_students, medium="rural") # -------------------------------------------BOXPLOTS---------------------------------- logging.info("Started Boxplots from {}".format(year)) save_boxplots(all_students, str(year), "general") save_boxplots(urban_students, str(year), "urban") save_boxplots(rural_students, str(year), "rural") logging.info("Finished Boxplots from {}".format(year)) # -------------------------------------------CIRCLE PLOTS------------------------------- logging.info("Started Circle Plots from {}".format(year)) colors = ['blue', 'red'] for cr_specialisation in ["matematica-informatica", "filologie"]: