diff --git a/problem1.py b/problem1.py new file mode 100644 index 0000000..dda3bfd --- /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.apply(lambda row: 0 if row['name'].startswith('M') or row['employee_id']%2==0 else row['salary'], axis =1) + return employees[['employee_id','bonus']].sort_values('employee_id') \ No newline at end of file diff --git a/problem2.py b/problem2.py new file mode 100644 index 0000000..8ac31bb --- /dev/null +++ b/problem2.py @@ -0,0 +1,6 @@ +import pandas as pd + +def fix_names(users: pd.DataFrame) -> pd.DataFrame: + users['name']=users['name'].str.capitalize() + return users.sort_values('user_id',ascending=True) + \ No newline at end of file diff --git a/problem3.py b/problem3.py new file mode 100644 index 0000000..c31b8e6 --- /dev/null +++ b/problem3.py @@ -0,0 +1,5 @@ +import pandas as pd + +def find_patients(patients: pd.DataFrame) -> pd.DataFrame: + df=patients[patients['conditions'].str.startswith('DIAB1') | patients['conditions'].str.contains(' DIAB1')] + return df \ No newline at end of file