Drawing Conclusions Quiz

Use the space below to explore store_data.csv to answer the quiz questions below.

In [1]:
# imports and load data
import pandas as pd
% matplotlib inline

df = pd.read_csv('store_data.csv')
df.head()
Out[1]:
week storeA storeB storeC storeD storeE
0 2014-05-04 2643 8257 3893 6231 1294
1 2014-05-11 6444 5736 5634 7092 2907
2 2014-05-18 9646 2552 4253 5447 4736
3 2014-05-25 5960 10740 8264 6063 949
4 2014-06-01 7412 7374 3208 3985 3023
In [2]:
# explore data
df.hist(figsize=(8, 8));
In [3]:
df.tail(20)
Out[3]:
week storeA storeB storeC storeD storeE
180 2017-10-15 8556 11984 4792 5995 2508
181 2017-10-22 3751 697 3990 4236 360
182 2017-10-29 4997 9759 4290 4568 2393
183 2017-11-05 12785 1800 6163 5157 578
184 2017-11-12 137 12261 5455 7695 2599
185 2017-11-19 9960 8529 4501 7631 505
186 2017-11-26 6866 5011 5401 4736 3232
187 2017-12-03 5179 3850 6121 6778 113
188 2017-12-10 9348 5624 5446 5448 227
189 2017-12-17 5310 8647 5680 7049 3578
190 2017-12-24 8976 9503 6240 3882 2890
191 2017-12-31 11875 1527 6711 5265 1701
192 2018-01-07 8978 11312 4158 5019 3842
193 2018-01-14 6963 4014 4215 7153 3097
194 2018-01-21 5553 3971 3761 6255 3071
195 2018-01-28 282 6351 7759 5558 1028
196 2018-02-04 4853 6503 4187 5956 1458
197 2018-02-11 9202 3677 4540 6186 243
198 2018-02-18 3512 7511 4151 5596 3501
199 2018-02-25 7560 6904 3569 5045 2585
In [4]:
# total sales for the last month
df.iloc[196:, 1:].sum()
Out[4]:
storeA    25127
storeB    24595
storeC    16447
storeD    22783
storeE     7787
dtype: int64
In [5]:
# average sales
df.mean()
Out[5]:
storeA    5865.480
storeB    6756.710
storeC    4942.105
storeD    5431.405
storeE    2580.025
dtype: float64
In [6]:
# sales on march 13, 2016
df[df['week'] == '2016-03-13']
Out[6]:
week storeA storeB storeC storeD storeE
97 2016-03-13 2054 1390 5112 5513 2536
In [7]:
# worst week for store C
df[df['storeC'] == df['storeC'].min()]
Out[7]:
week storeA storeB storeC storeD storeE
9 2014-07-06 8567 3228 927 3277 168
In [8]:
# total sales during most recent 3 month period
last_three_months = df[df['week'] >= '2017-12-01']
last_three_months.iloc[:, 1:].sum()  # exclude sum of week column
Out[8]:
storeA    87591
storeB    79394
storeC    66538
storeD    75190
storeE    27334
dtype: int64