Skip to content
Extraits de code Groupes Projets
Valider 8b8209d9 rédigé par Adrien Payen's avatar Adrien Payen
Parcourir les fichiers

project 95% done

parent a896ae29
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Fichier ajouté
......@@ -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):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter