Module 3
Deep Dive - Functions, OOPs, Modules, Errors and Exceptions
Case Study - II
1. Business challenge/requirement
Bank of Portugal runs marketing campaign to offer loans to clients. Loan is
offered to only clients with particular professions. List of successful campaigns (with
client data) is given in attached dataset. You have to come up with program which reads
the file and builds a set of unique profession list and given input profession of client –
system tells whether client is eligible to be approached for marketing campaign.
Answer:
import pandas as pd
import numpy as np
data = open("./bank-data.csv",'rb')
df = pd.read_csv(data) # read the data
unique_jobs = [jobs.lower() for jobs in np.unique(df['job'].values)] # converting all jobs to lower
print("Set of uniques jobs : ",unique_jobs) # printing set of unique jobs
flag = 1
while(flag==1):
job_input = input("Please enter your job : ") # enter jon input till user enter END
if job_input.lower() in unique_jobs: # making input case insensitive
print("Job is in the list. Eligible for loan.")
elif job_input.upper() == 'END':
flag = 0
else : print("job not found. Not eligible for loan")
age_dict = {'max':max(df['age'].values),'min':min(df['age'].values)} # dictionary to store max and
min age
print("max age of loan : ",age_dict.get('max')) # print max age from dictionary
print("min age of loan : ",age_dict.get('min')) # print min age from dictionary
******