Module 4 · pandas practice projects · Lesson 24 of 66

Project: e-commerce purchases

Dig into 10,000 online orders, including some harder text questions.

In this lesson · about 35 minutes

  • Filter on several conditions
  • Count with value_counts and sum
  • Pull pieces out of text columns with apply

This file has 10,000 made-up online purchases: address, browser, company, card details, email, job, language and purchase price. The people and card numbers are fake, generated for practice.

Each question loads the data as ecom. Make your last line the answer and press Check.

Take a first look

Exercise

Rows and columns

How many rows and columns are there? Give the answer as a tuple, (rows, columns).

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Average purchase

What is the average Purchase Price?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Highest and lowest purchase

Set highest and lowest to the highest and lowest purchase prices.

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

English speakers

How many people chose English, 'en', as their language on the site?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Lawyers

How many people have the job title "Lawyer"?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Morning or evening?

How many purchases were made in the AM and how many in the PM? (Column AM or PM.)

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Five most common jobs

What are the 5 most common job titles?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Lot 90 WT

Someone's purchase came from Lot "90 WT". What was its purchase price?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Whose card is this?

What is the email of the person with credit card number 4926535242672853? The card numbers are stored as numbers, so don't put quotes around it.

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Big American Express purchases

How many people paid with American Express and spent more than $95?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Hard: cards expiring in 2025

How many cards expire in 2025? CC Exp Date is text like 02/25 (month/year).

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercise

Hard: top email providers

What are the 5 most popular email hosts (like gmail.com or yahoo.com)?

Code that runs before yours
import pandas as pd
ecom = pd.read_csv('Ecommerce_Purchases.csv')

Exercises solved: 0 of 12

Tip: solve each exercise first. Press Check to test your code.

Noviq Academy's Data Science course is free and for learning. Python runs in your browser with Pyodide, which downloads about 20 MB the first time, plus a few more for scikit-learn. Your code and progress stay on this device. The salaries data is a sample of San Francisco's public pay records; the purchases, customers, housing, advertising and classified data are made up. The Titanic, tips, flights and iris data sets come from Seaborn's examples; the maps use public 2011 to 2014 US and world figures. The 911 data is a 20,000-call sample of Montgomery County, Pennsylvania's public 911 records; the movie ratings are the MovieLens 100K data from GroupLens Research; the reviews are a 3,000-review sample from the Yelp Dataset Challenge; the loans are public LendingClub data; the colleges are the College data from An Introduction to Statistical Learning; the bank notes, kyphosis and breast cancer data come from the UCI Machine Learning Repository. Spark and TensorFlow can't run in a browser, so those lessons use stand-ins that run here, and show the code for the real tools.