Mark As Completed Discussion

Sample Glassdoor Python Interview Questions

Now let's look at some questions based off Python Interview Questions from Glassdoor.

Level: Easy

After the success of Black Friday in the Cosmetics department at El Corte Inglés you've been asked to see what employee had the highest sales.

The dataset below is given, with employees by department and their sales. Find the Employee's ID, name and sales.

Coding Questions

PYTHON
1import pandas as pd
2import numpy as np
3
4# Filter to Cosmetics Department
5cosmetic_department = department_sales[department_sales['department'] == 'Cosmetics']
6
7# Create a rank
8cosmetic_department['rank'] = cosmetic_department['sales'].rank(method='min', ascending=False)
9top_employee = cosmetic_department[cosmetic_department['rank'] == 1][['emp_id','first_name','sales']]
10
11top_employee

Coding Questions

So, congratulations to John who'll be receiving a bonus reward for his efforts.

Level: Medium

The team at El Corte Inglés now want to find the employee with the lowest sales over Black Friday, and where they are based so HR can assess their overall capacity for the role.

You've been given an additional dataset, which refers back to the previously given dataset. Find the Employee's ID, name and sales.

Coding Questions

PYTHON
1import pandas as pd
2import numpy as np
3
4# Merge the datasets
5merged_df =  pd.merge(department_sales, emp_location, on='emp_id')
6
7# Find the minimum value
8min_sales = merged_df[merged_df['sales'] == merged_df['sales'].min()][['emp_id','first_name','emp_store']]
9
10min_sales

Coding Questions

Level: Hard

The team at Zara are reviewing their customers' transactions, and you have been tasked with locating the customer who has the third highest total transaction amount.

You've been given two datasets, with information on customers called customers and card_orders with information on card orders placed. Find the Customers ID, and total purchases.

Coding Questions

Coding Questions

PYTHON
1import pandas as pd
2# Merge the datasets
3merged = pd.merge(
4        customers, card_orders, left_on="id", right_on="cust_id", how="inner")
5
6# Get total purchases by customer id
7merged = merged.groupby(["cust_id"])["total_order_cost"].sum().to_frame('total')
8
9# Use rank function to get third customer
10merged["rank"] = merged["total"].rank(method='dense', ascending=False)
11result = merged[merged["rank"] == 3]
12result

Coding Questions

As you can see in this question we have a tie for third place, hence we use a .rank() function. If we used the .head() our answer would have been only half correct.