Answered step by step
Verified Expert Solution
Question
1 Approved Answer
THIS UTILIZES PANDAS AND PYTHON 2e) Match the employee name with company, age, gender Create a function with the following specifications Function name: employee_matcher Purpose:
THIS UTILIZES PANDAS AND PYTHON
2e) Match the employee name with company, age, gender Create a function with the following specifications Function name: employee_matcher Purpose: to match the employee name with the provided company, age, and gender Parameter(s): company (string), age (int), gender (string) Returns: The employee first_name and last_name like this: return first_name, last_name . Note: If there are multiple employees that fit the same description, first_name and last_name should return a list of all possible first names and last name i.e., ['Desmund', 'Kelby'] [Shepley', Tichner] Hint: There are many different ways to code this. An unelegant solution is to loop through df_employee and for each data item see if the company, age, and gender match i.e., for i in range (e, len(df_employee)): if (companydf employee.ix[i, company]): However! The solution above is very inefficient and long, so you should try to look into this: Google the df.loc method: It extracts pieces of the dataframe if it fulfills a certain condition. i.e df_employee.loc[df_employee['company'] company] If you need to convert your pandas data series into a list, you can do list(result) where result is a pandas "series" You can start with this outline def employee_matcher (company, age, gender): return first_name, last_name [18]: | # YOUR CODE HERE def employee_matcher(company, age, gender): f df-employee . loc [df-employee ["company.] company] & df-employee. loc[df-e - return first_name, last_name print (employee_matcher("google", 41, "Male"))Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started