Feat: add column description

This commit is contained in:
Bertrand Benjamin 2021-04-18 11:42:13 +02:00
parent 646314ad88
commit 1d234ea5fc

View File

@ -43,6 +43,18 @@ class CSVLoader(Loader):
""" Get config """ """ Get config """
return self._config return self._config
@property
def exam_columns(self):
return pd.Index(['name', 'date', 'term', 'origin', 'tribe', 'id'])
@property
def question_columns(self):
return pd.Index(['exercise', 'question', 'competence', 'theme', 'comment', 'score_rate', 'is_leveled', 'origin', 'exam_id', 'id'])
@property
def score_columns(self):
return pd.Index(['term', 'exam', 'date', 'exercise', 'question', 'competence', 'theme', 'comment', 'score_rate', 'is_leveled', 'origin', 'exam_id', 'question_id', 'student_name', 'score'])
def rename_columns(self, dataframe): def rename_columns(self, dataframe):
"""Rename dataframe column to match with `csv_fields` """Rename dataframe column to match with `csv_fields`
@ -84,8 +96,8 @@ class CSVLoader(Loader):
:example: :example:
>>> loader = CSVLoader("./test_config.yml") >>> loader = CSVLoader("./test_config.yml")
>>> exams = loader.get_exams(["Tribe1"]) >>> exams = loader.get_exams(["Tribe1"])
>>> exams.columns >>> all(exams.columns == loader.exam_columns)
Index(['name', 'date', 'term', 'origin', 'tribe', 'id'], dtype='object') True
>>> exams >>> exams
name date term origin tribe id name date term origin tribe id
0 DS 12/01/2021 1 example/Tribe1/210112_DS.csv Tribe1 DS_Tribe1 0 DS 12/01/2021 1 example/Tribe1/210112_DS.csv Tribe1 DS_Tribe1
@ -118,10 +130,7 @@ class CSVLoader(Loader):
:example: :example:
>>> loader = CSVLoader("./test_config.yml") >>> loader = CSVLoader("./test_config.yml")
>>> exams = loader.get_exams(["Tribe1"]) >>> exams = loader.get_exams(["Tribe1"])
>>> loader.get_exam_questions([exams.iloc[0]]).columns >>> all(loader.get_exam_questions([exams.iloc[0]]).columns == loader.score_columns)
Index(['exercise', 'question', 'competence', 'theme', 'comment', 'score_rate',
'is_leveled', 'origin', 'exam_id', 'id'],
dtype='object')
>>> questions = loader.get_exam_questions(exams) >>> questions = loader.get_exam_questions(exams)
>>> questions.iloc[0] >>> questions.iloc[0]
exercise Exercice 1 exercise Exercice 1
@ -172,11 +181,8 @@ class CSVLoader(Loader):
>>> exams = loader.get_exams(["Tribe1"]) >>> exams = loader.get_exams(["Tribe1"])
>>> questions = loader.get_exam_questions(exams) >>> questions = loader.get_exam_questions(exams)
>>> scores = loader.get_questions_scores(questions) >>> scores = loader.get_questions_scores(questions)
>>> scores.columns >>> all(scores.columns == loader.score_columns)
Index(['term', 'exam', 'date', 'exercise', 'question', 'competence', 'theme', True
'comment', 'score_rate', 'is_leveled', 'origin', 'exam_id',
'question_id', 'student_name', 'score'],
dtype='object')
>>> scores["student_name"].unique() >>> scores["student_name"].unique()
array(['Star Tice', 'Umberto Dingate', 'Starlin Crangle', array(['Star Tice', 'Umberto Dingate', 'Starlin Crangle',
'Humbert Bourcq', 'Gabriella Handyside', 'Stewart Eaves', 'Humbert Bourcq', 'Gabriella Handyside', 'Stewart Eaves',