Ecommerce purchases exercise

We have a dataset that contains personal (though fictional, of course) information about customers who are purchasing merchandise both online and from physical stores. Let’s imagine that your company wants to adjust their marketing to be more effective, and needs to examine the dataset for details about their customer base.

The solutions are given at the end of the exercises. There can be multiple solutions to every task.

The following data file does not need to be loaded. The dataset is provided with the exercise questions.

A sample preview of the dataset is provided below:

Use the code segment below to read the file and create a DataFrame:

Press + to interact
# First thing first, import Pandas :)
import pandas as pd
cust = pd.read_csv('Cust_Purch_FakeData.csv')
print(cust)

Task 1: Display the head

To see what the data looks like, display the first five rows of the dataset.

Input

N/A

Output

Must return the first five rows of the DataFrame.

Press + to interact
import pandas as pd
def display_first_5_Rows():
cust = pd.read_csv('Cust_Purch_FakeData.csv')
#Your Code Here

Task 2: Min, max, and mean of ages

Return the max, min, and mean of the ages of customers in the dataset. To return all the values, store the records in a list like this: [min, max, mean]. Follow this pattern for test cases.

Input

N/A

Output

A list containing the minimum, maximum, and mean of the ages.

Sample output

[min,max,mean]

Press + to interact
def min_max_mean_of_ages():
# Your Code Here
return None

Task 3: Count of structural engineers

Calculate how many customers have the profession “Structural Engineer”.

Input

N/A

Output

Return an integer value of the number of Structural Engineers in our DataFrame.

Press + to interact
def number_of_structural_engineers():
# Your Code Here
return None

Task 4: Count of male structural engineers

Calculate how many of the customers that have the profession “Structural Engineer” are male.

Input

N/A

Output

Return an integer value of the number of Structural Engineers who are male in our DataFrame.

Press + to interact
def number_of_male_structural_engineers():
# Your Code Here
return None

Task 5: Loyal customers

The company wants to send a thank you coupon to those who spent 100 CAD or more as a loyalty reward. Find out which customers spent 100 CAD or more, and return the list of their email addresses.

Use the 'price(CAD)' column to get the total CAD spent.

Input

N/A

Output

Return a list containing the emails of all the employees who have spent more than 100 CAD.

Sample output

['hav@jek.gs', 'get@jovu.ag', 'goh@tuwjaz.gd']

Press + to interact
def loyalCustomers():
# Your Code Here
return None