From 8e1c4cd5c9a72a64c520d40c520ad10c4b4d9291 Mon Sep 17 00:00:00 2001 From: Hinduja Cheela Date: Thu, 12 Jun 2025 01:56:34 -0500 Subject: [PATCH] Solved three problems --- problem1.py | 6 ++++++ problem2.py | 6 ++++++ problem3.py | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 problem1.py create mode 100644 problem2.py create mode 100644 problem3.py 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