Тема: Допоможіть, будь ласка, скласти блок-схему
Допоможіть, будь ласка, скласти блок-схему
import pandas as pd
def sort_students(df: pd.DataFrame, ascending: bool = True) -> pd.DataFrame:
"""
Sort students by the year of their birth
Also resetting index for clear view of the dataframe
:ascending:
:df:
:return:
"""
df = df.sort_values("birth_date", ascending=ascending).reset_index(drop=True)
return df
def edit_dataframe(df: pd.DataFrame) -> pd.DataFrame:
"""
Editing data to acceptable level
:df:
:return:
"""
df["birth_date"] = pd.to_datetime(df["birth_date"], dayfirst=True)
df["grades"] = df["grades"].str.strip('[]').str.split(';')
return df
if name == "__main__":
df = pd.read_csv('student_list.csv')
#prerpocessing
df = edit_dataframe(df)
df = sort_students(df, ascending=False)
print(df)