diff --git a/Bonus.txt b/Bonus.txt new file mode 100644 index 0000000..3c2406f --- /dev/null +++ b/Bonus.txt @@ -0,0 +1,5 @@ +import pandas as pd + +def calculate_special_bonus(employees: pd.DataFrame) -> pd.DataFrame: + employees['bonus'] = employees.apply(lambda x: x['salary'] if x['employee_id']%2 != 0 and not x['name'].startswith('M') else 0, axis = 1) + return employees[['employee_id','bonus']].sort_values(by = 'employee_id') \ No newline at end of file diff --git a/Fix_Names.txt b/Fix_Names.txt new file mode 100644 index 0000000..ef6feaf --- /dev/null +++ b/Fix_Names.txt @@ -0,0 +1,5 @@ +import pandas as pd + +def fix_names(users: pd.DataFrame) -> pd.DataFrame: + users['name'] = users['name'].str[0].str.upper()+ users['name'].str[1:].str.lower() + return users.sort_values('user_id') \ No newline at end of file diff --git a/Patients_With_Conditions.txt b/Patients_With_Conditions.txt new file mode 100644 index 0000000..cf63d3c --- /dev/null +++ b/Patients_With_Conditions.txt @@ -0,0 +1,4 @@ +import pandas as pd + +def find_patients(patients: pd.DataFrame) -> pd.DataFrame: + return patients[patients['conditions'].str.contains(r'(^|\s)DIAB1', regex=True)] \ No newline at end of file