diff --git a/Problem1.py b/Problem1.py new file mode 100644 index 0000000..9e0bfa8 --- /dev/null +++ b/Problem1.py @@ -0,0 +1,6 @@ +import pandas as pd + +def calculate_special_bonus(employees: pd.DataFrame) -> pd.DataFrame: + employees['bonus']=employees.salary + employees.loc[((employees.employee_id%2==0) | (employees.name.str.startswith('M'))), 'bonus']=0 + return employees[['employee_id', 'bonus']].sort_values(by='employee_id') \ No newline at end of file diff --git a/Problem2.py b/Problem2.py new file mode 100644 index 0000000..a1c0d34 --- /dev/null +++ b/Problem2.py @@ -0,0 +1,7 @@ +import pandas as pd + +def fix_names(users: pd.DataFrame) -> pd.DataFrame: + users['name']=users['name'].str.capitalize() + users.sort_values(by='user_id',ascending=True,inplace=True) + return users + \ No newline at end of file diff --git a/Problem3.py b/Problem3.py new file mode 100644 index 0000000..26a9474 --- /dev/null +++ b/Problem3.py @@ -0,0 +1,6 @@ +import pandas as pd + +def find_patients(patients: pd.DataFrame) -> pd.DataFrame: + patients_with_diabetes = patients[patients['conditions'].str.contains(r'\bDIAB1')] + result_df = patients_with_diabetes[['patient_id', 'patient_name', 'conditions']] + return result_df \ No newline at end of file