Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#11 Add start_date column and sort the dataframe #12

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions fais/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 ""