What can we do with Pandas?

In this example, we'll be working with data from ShoeFly.com, a fictional online shoe store.

In [1]:
# Before we analyze anything, we need to import pandas
import pandas as pd

We can load data into Pandas from a csv (comma-separated variable) file. This data represents purchases from ShoeFly.com.

In [2]:
df = pd.read_csv('shoefly_orders.csv')

Let's examine the first 10 rows of our data!

In [3]:
df.head(10)
Out[3]:
id first_name last_name email shoe_type shoe_material shoe_color
0 54791 Rebecca Lindsay RebeccaLindsay57@hotmail.com clogs faux-leather black
1 53450 Emily Joyce EmilyJoyce25@gmail.com ballet flats faux-leather navy
2 91987 Joyce Waller Joyce.Waller@gmail.com sandals fabric black
3 14437 Justin Erickson Justin.Erickson@outlook.com clogs faux-leather red
4 79357 Andrew Banks AB4318@gmail.com boots leather brown
5 52386 Julie Marsh JulieMarsh59@gmail.com sandals fabric black
6 20487 Thomas Jensen TJ5470@gmail.com clogs fabric navy
7 76971 Janice Hicks Janice.Hicks@gmail.com clogs faux-leather navy
8 21586 Gabriel Porter GabrielPorter24@gmail.com clogs leather brown
9 62083 Frances Palmer FrancesPalmer50@gmail.com wedges leather white

Let's select everyone who ordered black sandals.

In [4]:
df[(df.shoe_type == 'sandals') & (df.shoe_color == 'black')]
Out[4]:
id first_name last_name email shoe_type shoe_material shoe_color
2 91987 Joyce Waller Joyce.Waller@gmail.com sandals fabric black
5 52386 Julie Marsh JulieMarsh59@gmail.com sandals fabric black

Let's see what Susan Dennis ordered.

In [5]:
df[(df.first_name == 'Susan') & (df.last_name == 'Dennis')]
Out[5]:
id first_name last_name email shoe_type shoe_material shoe_color
12 45832 Susan Dennis SusanDennis58@gmail.com ballet flats fabric white

It looks like Susan ordered white fabric ballet flats!