From b575b815e91c6b0a161fcd4483e9799f190289bd Mon Sep 17 00:00:00 2001 From: "jingjinggit config --global user.email 745287546@qq.com" <745287546@qq.com> Date: Wed, 19 Jan 2022 18:05:00 +1100 Subject: [PATCH] #11 Add start_date column and sort the dataframe --- fais/commands.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fais/commands.py b/fais/commands.py index 8d103cf..2b8b169 100644 --- a/fais/commands.py +++ b/fais/commands.py @@ -406,6 +406,10 @@ def student(config, uid, session): df["Sex"] = sex df = df.iloc[:, [8, 9, 10, 11, 7, 0, 1, 2, 3, 4, 5, 6]] + + # Add start_date column + df['start_date'] = df.apply(lambda row: start_date(row), axis=1) + df = df.sort_values(["start_date", "Final"], ascending=(True, True)) click.echo(df.to_csv(index=False).strip()) if not config.fake: @@ -476,3 +480,21 @@ def students(config, pattern): if not config.fake: utils.logout() + +def start_date(row): + sem = row["Sem/Year"].split("/")[0] + year = row["Sem/Year"].split("/")[1] + if sem == "Sum": + return year+"-"+"0" + elif sem == "S1": + return year+"-"+"1" + elif sem == "Aut": + return year+"-"+"2" + elif sem == "Win": + return year+"-"+"3" + elif sem == "S2": + return year+"-"+"4" + elif sem == "Spr": + return year+"-"+"5" + else: + return ""