From 95856aee0bf222521ece95c141f84eea9932046e Mon Sep 17 00:00:00 2001 From: Eljakim Herrewijnen Date: Sat, 18 Sep 2021 13:21:17 +0200 Subject: [PATCH] Able to get data from a subject with a period --- main.py | 2 ++ plots.py | 11 +++++++++++ templates/index.html | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index fc2a2f4..3ea6872 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,9 @@ from flaskapp import * from plots import Cijferlijst +import matplotlib.pyplot as plt if __name__ == "__main__": cf = Cijferlijst() + data = cf.GetSubjectByYear("godsdienst", "2010/2011") cf.CalculateMedian() RunWeb() \ No newline at end of file diff --git a/plots.py b/plots.py index 06c47c3..e390f64 100644 --- a/plots.py +++ b/plots.py @@ -7,6 +7,17 @@ class Cijferlijst: def __init__(self, grade_list=GRADE_LIST): self.grade_list = grade_list self.ps = pd.read_csv(GRADE_LIST, skiprows=2, sep=';') + + ''' + Get all data from a subject and a (yearly) period: + GetSubjectByYear("godsdienst", "2010/2011") + ''' + def GetSubjectByYear(self, subject, year): + if(type(subject) == str and type(year) == str): + select_year = self.ps[self.ps['Schooljaar(Voortgangsdossier)'] == year] + return select_year[select_year["Vak(Voortgangsdossier)"] == subject] + else: + return False def iets(self): print(self.grade_list) diff --git a/templates/index.html b/templates/index.html index c086203..35b719a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -6,7 +6,7 @@ - + {% block body %}{% endblock %}