diff --git a/Data_Base.xlsx b/Data_Base.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..d9513acf2c25892a5e2e901484c9020144c85240 Binary files /dev/null and b/Data_Base.xlsx differ diff --git a/projet_personnel/algorithme_gestion_etudiants.py b/projet_personnel/algorithme_gestion_etudiants.py index 49466a2d17fe403d8c4127aa11683542d4721f70..1de243ae9225b461f10dfb871a12a74bbc3986b4 100644 --- a/projet_personnel/algorithme_gestion_etudiants.py +++ b/projet_personnel/algorithme_gestion_etudiants.py @@ -539,54 +539,83 @@ def sort_descending(data): export_option(sorted_data) def sort_by_date(data): + data['Date of Birth'] = pd.to_datetime(data['Date of Birth'], format='%d/%m/%Y') sorted_data = data.sort_values(by='Date of Birth') + sorted_data['Date of Birth'] = sorted_data['Date of Birth'].dt.strftime('%d/%m/%Y') see_the_data(sorted_data, columns_to_show=['Firstname', 'Lastname', 'Date of Birth']) export_option(sorted_data) def sort_by_age(data): - data['Age'] = (pd.to_datetime('today') - pd.to_datetime(data['Date of Birth'])).astype('<m8[Y]') + data['Date of Birth'] = pd.to_datetime(data['Date of Birth'], format='%d/%m/%Y') + today = pd.to_datetime('today') + age_timedelta = today - data['Date of Birth'] + data['Age'] = (age_timedelta / pd.Timedelta(days=365.25)).astype(int) sorted_data = data.sort_values(by='Age', ascending=True) see_the_data(sorted_data, columns_to_show=['Firstname', 'Lastname', 'Age']) export_option(sorted_data) - - - def sort_by_matricule(data): sorted_data = data.sort_values(by='Matricule', ascending=True) see_the_data(sorted_data, columns_to_show=['Firstname', 'Lastname', 'Matricule']) export_option(sorted_data) def sort_by_academic_year(data): - sorted_data = data.sort_values(by='AcademicYear', ascending=True) - see_the_data(sorted_data, columns_to_show=['Firstname', 'Lastname', 'AcademicYear']) + sorted_data = data.sort_values(by='Academic Year', ascending=True) + see_the_data(sorted_data, columns_to_show=['Firstname', 'Lastname', 'Academic Year']) export_option(sorted_data) - - # attention il faut pouvoir matcher ceci avec les résultats obtenus def sort_passed(data): - passed_data = data[data['PassedCourse'] == True] - see_the_data(passed_data, columns_to_show=['Firstname', 'Lastname', 'PassedCourse']) + course_columns = data.columns[11:] + print("Available Courses:") + for i, course in enumerate(course_columns, 1): + print(f"{i}. {course}") + + while True: + try: + choice = int(input("Enter the number of the course you want to display: ")) + selected_course = course_columns[choice - 1] + break + except (ValueError, IndexError): + print("Invalid choice. Please enter a valid number.") + + passed_data = data[data[selected_course] >= 10] + + # Notez que 'selected_course' doit être passé comme une liste pour inclure la note du cours dans 'columns_to_show' + see_the_data(passed_data, columns_to_show=['Firstname', 'Lastname', selected_course]) export_option(passed_data) -def sort_failed(data): - failed_data = data[data['PassedCourse'] == False] - see_the_data(failed_data, columns_to_show=['Firstname', 'Lastname', 'PassedCourse']) - export_option(failed_data) +def sort_failed(data): + course_columns = data.columns[11:] + print("Available Courses:") + for i, course in enumerate(course_columns, 1): + print(f"{i}. {course}") + + while True: + try: + choice = int(input("Enter the number of the course you want to display: ")) + selected_course = course_columns[choice - 1] + break + except (ValueError, IndexError): + print("Invalid choice. Please enter a valid number.") + failed_data = data[data[selected_course] < 10] + + # Notez que 'selected_course' doit être passé comme une liste pour inclure la note du cours dans 'columns_to_show' + see_the_data( failed_data, columns_to_show=['Firstname', 'Lastname', selected_course]) + export_option( failed_data) def sort_bachelor(data): - bachelor_data = data[data['Academic Year'] == 'BAC1' or 'BAC2' or 'BAC3'] + bachelor_data = data[data['Academic Year'].isin(['BAC1', 'BAC2', 'BAC3'])].sort_values(by=['Academic Year', 'Lastname'], ascending=[True, True]) see_the_data(bachelor_data, columns_to_show=['Firstname', 'Lastname', 'Academic Year']) export_option(bachelor_data) def sort_master(data): - master_data = data[data['Academic Year'] == 'MA1' or 'MA2'] + master_data = data[data['Academic Year'].isin(['MA1', 'MA2'])].sort_values(by=['Academic Year', 'Lastname'], ascending=[True, True]) see_the_data(master_data, columns_to_show=['Firstname', 'Lastname', 'Academic Year']) export_option(master_data) @@ -598,6 +627,7 @@ def export_option(data): filename = filename + '.xlsx' export_data_to_excel(data, filename) + def export_data_to_excel(data, filename): data.to_excel(filename, index=False) print(f"\nData exported to {filename}") @@ -613,20 +643,6 @@ def see_the_data(data, columns_to_show=None): -# Example usage -# Replace 'data' with the name of your DataFrame - - - - - - - - - - - - # STATS def statistics_analysis(data):