Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Problem1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pandas as pd

def calculate_special_bonus(employees: pd.DataFrame) -> pd.DataFrame:
result = []
for i in range(len(employees)):
e_id = employees['employee_id'][i]
name = employees['name'][i]
salary = employees['salary'][i]

if (e_id % 2 !=0) and (name[0]!='M'):
result.append([e_id, employees['salary'][i]])
else:
result.append([e_id, 0])
return pd.DataFrame(result, columns = ['employee_id','bonus']).sort_values(by = ['employee_id'])
5 changes: 5 additions & 0 deletions Problem2.py
Original file line number Diff line number Diff line change
@@ -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(by = ['user_id'])
14 changes: 14 additions & 0 deletions Problem3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pandas as pd

def find_patients(patients: pd.DataFrame) -> pd.DataFrame:
result = []
for i in range(len(patients)):
p_id = patients['patient_id'][i]
p_name = patients['patient_name'][i]
conditions = patients['conditions'][i]
for condition in conditions.split():
if condition.startswith('DIAB1'):
result.append([p_id,p_name,conditions])
break
return pd.DataFrame(result, columns = ['patient_id','patient_name','conditions'])