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