Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [1]:

import numpy as np
import pandas as pd
import os
import seaborn as sns
%matplotlib inline
pd.set_option('display.float_format', lambda x: '%.2f' % x)
import scipy.stats as stats
import matplotlib.pyplot as plt

In [2]:

df = pd.read_csv('Mcdonald .csv')

In [3]:

df.head()

Out[3]:

Total Saturated
Serving Calories Total Fat (% Saturated Fat (% Trans
Category Item Calories
Size from Fat Fat Daily Fat Daily Fat
Value) Value)

Egg 4.8 oz
0 Breakfast 300 120 13.00 20 5.00 25 0.00
McMuffin (136 g)

Egg
4.8 oz
1 Breakfast White 250 70 8.00 12 3.00 15 0.00
(135 g)
Delight

Sausage 3.9 oz
2 Breakfast 370 200 23.00 35 8.00 42 0.00
McMuffin (111 g)

Sausage
5.7 oz
3 Breakfast McMuffin 450 250 28.00 43 10.00 52 0.00
(161 g)
with Egg

Sausage
McMuffin 5.7 oz
4 Breakfast 400 210 23.00 35 8.00 42 0.00
with Egg (161 g)
Whites

5 rows × 24 columns

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 1/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [4]:

df.describe().T

Out[4]:

count mean std min 25% 50% 75% max

Calories 260.00 368.27 240.27 0.00 210.00 340.00 500.00 1880.00

Calories from Fat 260.00 127.10 127.88 0.00 20.00 100.00 200.00 1060.00

Total Fat 260.00 14.17 14.21 0.00 2.38 11.00 22.25 118.00

Total Fat (% Daily Value) 260.00 21.82 21.89 0.00 3.75 17.00 35.00 182.00

Saturated Fat 260.00 6.01 5.32 0.00 1.00 5.00 10.00 20.00

Saturated Fat (% Daily Value) 260.00 29.97 26.64 0.00 4.75 24.00 48.00 102.00

Trans Fat 260.00 0.20 0.43 0.00 0.00 0.00 0.00 2.50

Cholesterol 260.00 54.94 87.27 0.00 5.00 35.00 65.00 575.00

Cholesterol (% Daily Value) 260.00 18.39 29.09 0.00 2.00 11.00 21.25 192.00

Sodium 260.00 495.75 577.03 0.00 107.50 190.00 865.00 3600.00

Sodium (% Daily Value) 260.00 20.68 24.03 0.00 4.75 8.00 36.25 150.00

Carbohydrates 260.00 47.35 28.25 0.00 30.00 44.00 60.00 141.00

Carbohydrates (% Daily Value) 260.00 15.78 9.42 0.00 10.00 15.00 20.00 47.00

Dietary Fiber 260.00 1.63 1.57 0.00 0.00 1.00 3.00 7.00

Dietary Fiber (% Daily Value) 260.00 6.53 6.31 0.00 0.00 5.00 10.00 28.00

Sugars 260.00 29.42 28.68 0.00 5.75 17.50 48.00 128.00

Protein 260.00 13.34 11.43 0.00 4.00 12.00 19.00 87.00

Vitamin A (% Daily Value) 260.00 13.43 24.37 0.00 2.00 8.00 15.00 170.00

Vitamin C (% Daily Value) 260.00 8.53 26.35 0.00 0.00 0.00 4.00 240.00

Calcium (% Daily Value) 260.00 20.97 17.02 0.00 6.00 20.00 30.00 70.00

Iron (% Daily Value) 260.00 7.73 8.72 0.00 0.00 4.00 15.00 40.00

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 2/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [5]:

df.info()

<class 'pandas.core.frame.DataFrame'>

RangeIndex: 260 entries, 0 to 259

Data columns (total 24 columns):

# Column Non-Null Count Dtype

--- ------ -------------- -----

0 Category 260 non-null object

1 Item 260 non-null object

2 Serving Size 260 non-null object

3 Calories 260 non-null int64

4 Calories from Fat 260 non-null int64

5 Total Fat 260 non-null float64

6 Total Fat (% Daily Value) 260 non-null int64

7 Saturated Fat 260 non-null float64

8 Saturated Fat (% Daily Value) 260 non-null int64

9 Trans Fat 260 non-null float64

10 Cholesterol 260 non-null int64

11 Cholesterol (% Daily Value) 260 non-null int64

12 Sodium 260 non-null int64

13 Sodium (% Daily Value) 260 non-null int64

14 Carbohydrates 260 non-null int64

15 Carbohydrates (% Daily Value) 260 non-null int64

16 Dietary Fiber 260 non-null int64

17 Dietary Fiber (% Daily Value) 260 non-null int64

18 Sugars 260 non-null int64

19 Protein 260 non-null int64

20 Vitamin A (% Daily Value) 260 non-null int64

21 Vitamin C (% Daily Value) 260 non-null int64

22 Calcium (% Daily Value) 260 non-null int64

23 Iron (% Daily Value) 260 non-null int64

dtypes: float64(3), int64(18), object(3)

memory usage: 48.9+ KB

In [6]:

df['Category'].value_counts()

Out[6]:

Coffee & Tea 95

Breakfast 42

Smoothies & Shakes 28

Chicken & Fish 27

Beverages 27

Beef & Pork 15

Snacks & Sides 13

Desserts 7

Salads 6

Name: Category, dtype: int64

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 3/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [7]:

plt.figure(figsize=(18,9))
df['Category'].hist()

Out[7]:

<AxesSubplot:>

In [8]:

plt.figure(figsize=(18,9))
sns.boxplot(data=df[['Calories', 'Calories from Fat','Total Fat','Saturated Fat']]);

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 4/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [9]:

Correlation = df.corr()
Correlation

Out[9]:

Total Saturated
Chol
Calories Total Fat (% Saturated Fat (% Trans
Calories Cholesterol (%
from Fat Fat Daily Fat Daily Fat
Value) Value)

Calories 1.00 0.90 0.90 0.90 0.85 0.85 0.52 0.60

Calories from
0.90 1.00 1.00 1.00 0.85 0.85 0.43 0.68
Fat

Total Fat 0.90 1.00 1.00 1.00 0.85 0.85 0.43 0.68

Total Fat (%
0.90 1.00 1.00 1.00 0.85 0.85 0.43 0.68
Daily Value)

Saturated Fat 0.85 0.85 0.85 0.85 1.00 1.00 0.62 0.63

Saturated Fat
(% Daily 0.85 0.85 0.85 0.85 1.00 1.00 0.62 0.63
Value)

Trans Fat 0.52 0.43 0.43 0.43 0.62 0.62 1.00 0.25

Cholesterol 0.60 0.68 0.68 0.68 0.63 0.63 0.25 1.00

Cholesterol (%
0.60 0.68 0.68 0.68 0.63 0.63 0.25 1.00
Daily Value)

Sodium 0.71 0.85 0.85 0.85 0.58 0.59 0.19 0.62

Sodium (%
0.71 0.85 0.85 0.85 0.59 0.59 0.19 0.62
Daily Value)

Carbohydrates 0.78 0.46 0.46 0.46 0.59 0.59 0.46 0.27

Carbohydrates
(% Daily 0.78 0.46 0.46 0.46 0.59 0.59 0.46 0.27
Value)

Dietary Fiber 0.54 0.58 0.58 0.58 0.35 0.36 0.05 0.44

Dietary Fiber
(% Daily 0.54 0.58 0.58 0.58 0.35 0.35 0.06 0.44
Value)

Sugars 0.26 -0.12 -0.12 -0.12 0.20 0.20 0.33 -0.14

Protein 0.79 0.81 0.81 0.81 0.60 0.61 0.39 0.56

Vitamin A (%
0.11 0.06 0.05 0.05 0.06 0.07 0.08 0.08
Daily Value)

Vitamin C (%
-0.07 -0.09 -0.09 -0.09 -0.18 -0.18 -0.08 -0.08
Daily Value)

Calcium (%
0.43 0.16 0.16 0.16 0.40 0.40 0.39 0.13
Daily Value)

Iron (% Daily
0.64 0.74 0.73 0.74 0.58 0.58 0.33 0.65
Value)

21 rows × 21 columns

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 5/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [10]:

plt.figure(figsize=(18,9))
sns.heatmap(Correlation,annot=True)

Out[10]:

<AxesSubplot:>

In [11]:

df['Category'].nunique()
print('The number of Categories is -', df['Category'].nunique())

The number of Categories is - 9

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 6/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [12]:

df['Category'].unique()
from pandas import DataFrame
Category_List = sorted(df['Category'].unique())
type(sorted(df['Category'].unique()))
a = pd.DataFrame(Category_List,columns=[''])
a.index += 1
print('\n \n Let us view the different food categories that are available to us :- \n \n ',

Let us view the different food categories that are available to us :-

1 Beef & Pork

2 Beverages

3 Breakfast

4 Chicken & Fish

5 Coffee & Tea

6 Desserts

7 Salads

8 Smoothies & Shakes

9 Snacks & Sides

In [14]:

b = pd.pivot_table(df, 'Cholesterol (% Daily Value)', index=['Category'])


Result = b.sort_values (('Cholesterol (% Daily Value)'), ascending=False)
Result

Out[14]:

Cholesterol (% Daily Value)

Category

Breakfast 50.95

Beef & Pork 28.93

Chicken & Fish 25.22

Salads 17.33

Smoothies & Shakes 14.71

Coffee & Tea 9.38

Snacks & Sides 6.23

Desserts 4.86

Beverages 0.19

In [15]:

df['Item'].nunique()
print('\n \n The different type of Food items available at Mcdonald are -', df['Item'].nuni

The different type of Food items available at Mcdonald are - 260

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 7/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [17]:

df['Item'].head(20)

Out[17]:

0 Egg McMuffin

1 Egg White Delight

2 Sausage McMuffin

3 Sausage McMuffin with Egg

4 Sausage McMuffin with Egg Whites

5 Steak & Egg McMuffin

6 Bacon, Egg & Cheese Biscuit (Regular Biscuit)

7 Bacon, Egg & Cheese Biscuit (Large Biscuit)

8 Bacon, Egg & Cheese Biscuit with Egg Whites (R...

9 Bacon, Egg & Cheese Biscuit with Egg Whites (L...

10 Sausage Biscuit (Regular Biscuit)

11 Sausage Biscuit (Large Biscuit)

12 Sausage Biscuit with Egg (Regular Biscuit)

13 Sausage Biscuit with Egg (Large Biscuit)

14 Sausage Biscuit with Egg Whites (Regular Biscuit)

15 Sausage Biscuit with Egg Whites (Large Biscuit)

16 Southern Style Chicken Biscuit (Regular Biscuit)

17 Southern Style Chicken Biscuit (Large Biscuit)

18 Steak & Egg Biscuit (Regular Biscuit)

19 Bacon, Egg & Cheese McGriddles

Name: Item, dtype: object

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 8/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [21]:

c = pd.pivot_table(df, 'Sodium', index=['Item'])


Result_1 = c.sort_values(('Sodium'), ascending=False)
Result_1.head(20)

Out[21]:

Sodium

Item

Chicken McNuggets (40 piece) 3600

Big Breakfast with Hotcakes and Egg Whites (Large Biscuit) 2290

Big Breakfast with Hotcakes (Large Biscuit) 2260

Big Breakfast with Hotcakes and Egg Whites (Regular Biscuit) 2170

Big Breakfast with Hotcakes (Regular Biscuit) 2150

Chicken McNuggets (20 piece) 1800

Bacon Clubhouse Crispy Chicken Sandwich 1720

Big Breakfast with Egg Whites (Large Biscuit) 1700

Big Breakfast (Large Biscuit) 1680

Big Breakfast with Egg Whites (Regular Biscuit) 1590

Bacon Clubhouse Grilled Chicken Sandwich 1560

Big Breakfast (Regular Biscuit) 1560

Premium McWrap Chicken & Bacon (Crispy Chicken) 1540

Steak, Egg & Cheese Bagel 1510

Bacon, Egg & Cheese Bagel with Egg Whites 1480

Bacon, Egg & Cheese Bagel 1480

Premium McWrap Southwest Chicken (Crispy Chicken) 1480

Steak & Egg Biscuit (Regular Biscuit) 1470

Bacon Clubhouse Burger 1470

Quarter Pounder with Bacon & Cheese 1440

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 9/10
11/2/21, 4:45 PM Mcdonald - Jupyter Notebook

In [23]:

c = pd.pivot_table(df, 'Saturated Fat', index=['Item'])


Result_1 = c.sort_values(('Saturated Fat'), ascending=False)
Result_1.head(20)

Out[23]:

Saturated Fat

Item

McFlurry with M&M’s Candies (Medium) 20.00

Big Breakfast with Hotcakes (Large Biscuit) 20.00

Chicken McNuggets (40 piece) 20.00

Frappé Chocolate Chip (Large) 20.00

Double Quarter Pounder with Cheese 19.00

Big Breakfast with Hotcakes (Regular Biscuit) 19.00

Big Breakfast (Large Biscuit) 18.00

Frappé Mocha (Large) 17.00

Frappé Chocolate Chip (Medium) 17.00

Big Breakfast (Regular Biscuit) 17.00

Frappé Caramel (Large) 17.00

Big Breakfast with Hotcakes and Egg Whites (Regular Biscuit) 16.00

Big Breakfast with Hotcakes and Egg Whites (Large Biscuit) 16.00

Steak & Egg Biscuit (Regular Biscuit) 16.00

Strawberry Shake (Large) 15.00

Sausage Biscuit with Egg (Large Biscuit) 15.00

Vanilla Shake (Large) 15.00

Chocolate Shake (Large) 15.00

Frappé Caramel (Medium) 15.00

Shamrock Shake (Large) 15.00

In [ ]:

localhost:8888/notebooks/Downloads/Mcdonald.ipynb 10/10

You might also like