I have to define a function that selects whoever has sales related job title from a data frame, and it has to include the function below:
def isSales(job):
a = job.lower()
if 'sales' in a:
return 'True'
Basically it is filtering of a data frame, but the function will go through another function and will include the ones with job titles that has 'sales' in it.
here is a fake dataframe that you can use.
employee = {'EmployeeID' : [0,1,2,3,4,5,6,7,8,9],
'FirstName' : ['a','b','c','d','e','f','g','h','i','j'],
'LastName' : ['a','b','c','d','e','f','g','h','i','j'],
'MiddleName' : ['a','b','c','d','e','f','g','h','i',None]
'JobTitle : ['Production Supervisor', 'Technician', 'Buyer', 'Sales Manager', 'Data Scientist', 'President', 'Vice President of Sales', 'Manager', 'Stocker', 'Sales Accountant'}
employee_df = pd.DataFrame(employee)
after I define it, I have to check with this code and see if it works properly
sales_df = filterSales(employees_df)
print "Number of rows: %d\nNumber of cols: %d\n" % (sales_df.shape[0], sales_df.shape[1])
print "Head of index: %s\n" % (sales_df.index[:10])
print "Record of sales employee with ID=280\n"
print sales_df.loc[280]
Thank you so much guys.