In [3]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

In [15]:
df = pd.read_csv('~/Downloads/fatherly-iterable.csv',index_col=False)

In [16]:
df.head(1)


Out[16]:
Campaign ID Campaign Name Medium Updated Launch Date Status Experiment Name Experiment ID Sent Delivered ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
0 48476 WEEK_143_SUN Email Aug 5, 2016 - 06:47 PM Aug 7, 2016 - 08:00 AM Finished - - 87961 86125 ... 0.242991 0 0 0 118 0.001342 1836 0.020873 2 0.000023

1 rows × 29 columns


In [6]:
df.columns


Out[6]:
Index([u'Campaign ID', u'Campaign Name', u'Medium', u'Updated', u'Launch Date',
       u'Status', u'Experiment Name', u'Experiment ID', u'Sent', u'Delivered',
       u'Unique Opens', u'Unique Open Rate', u'Total Opens',
       u'Total Open Rate', u'Unique Clicks', u'Unique Click Rate',
       u'Total Clicks', u'Total Click Rate', u'Unique Clicks / Opens',
       u'Total Clicks / Opens', u'Purchases', u'Revenue', u'Revenue / Mille',
       u'Unsubscribes', u'Unsubscribe Rate', u'Bounces', u'Bounce Rate',
       u'Spams', u'Spam Rate'],
      dtype='object')

In [18]:
df = df.drop(['Medium','Updated','Campaign ID','Status','Experiment Name','Experiment ID'],axis=1)

In [19]:
df.head(1)


Out[19]:
Campaign Name Launch Date Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
0 WEEK_143_SUN Aug 7, 2016 - 08:00 AM 87961 86125 963 0.010948 1424 0.016189 168 0.00191 ... 0.242991 0 0 0 118 0.001342 1836 0.020873 2 0.000023

1 rows × 23 columns


In [20]:
df['Launch Date'] = df['Launch Date'].apply(lambda x: x.split(" - ")[0])

In [22]:
df['Launch Date'] = pd.to_datetime(df['Launch Date'])

In [23]:
df.head(1)


Out[23]:
Campaign Name Launch Date Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
0 WEEK_143_SUN 2016-08-07 87961 86125 963 0.010948 1424 0.016189 168 0.00191 ... 0.242991 0 0 0 118 0.001342 1836 0.020873 2 0.000023

1 rows × 23 columns


In [24]:
df.describe()


Out[24]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
count 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000 ... 152.000000 152.0 152.0 152.0 152.000000 152.000000 152.000000 152.000000 152.000000 152.000000
mean 130498.894737 128708.657895 20542.006579 0.183897 34267.394737 0.377818 4324.361842 0.037253 6450.460526 0.063197 ... 0.311964 0.0 0.0 0.0 421.552632 0.004096 1790.236842 0.025011 32.236842 0.000330
std 60972.561909 61050.711519 9793.625505 0.141679 17284.805285 0.658961 2307.739393 0.036194 3399.249609 0.113622 ... 0.141609 0.0 0.0 0.0 202.184585 0.006849 6205.660010 0.133342 21.670542 0.000671
min 1.000000 -1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 ... 0.000000 0.0 0.0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
25% 95014.250000 94323.750000 15851.250000 0.149435 25811.250000 0.238388 3178.500000 0.024282 4712.000000 0.034758 ... 0.246035 0.0 0.0 0.0 315.500000 0.002187 779.000000 0.007535 19.000000 0.000112
50% 116451.500000 115445.500000 20117.500000 0.168241 34181.000000 0.281010 4298.000000 0.035048 6677.500000 0.052756 ... 0.308466 0.0 0.0 0.0 426.000000 0.002984 1150.500000 0.008606 30.500000 0.000261
75% 190548.750000 189248.500000 29091.750000 0.183298 46851.000000 0.307755 5634.500000 0.044395 8457.500000 0.068115 ... 0.378799 0.0 0.0 0.0 530.750000 0.004148 1871.250000 0.009911 45.000000 0.000395
max 224965.000000 222151.000000 35785.000000 1.000000 100394.000000 6.000000 11127.000000 0.400000 14961.000000 1.200000 ... 1.200000 0.0 0.0 0.0 1212.000000 0.080502 77134.000000 1.333333 190.000000 0.008102

8 rows × 21 columns


In [25]:
df = df[df['Sent']>50000]

In [27]:
df.describe()


Out[27]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
count 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 ... 136.000000 136.0 136.0 136.0 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000
mean 143790.595588 141819.014706 22462.036765 0.157925 37380.823529 0.262236 4719.367647 0.034038 7034.705882 0.051110 ... 0.313497 0.0 0.0 0.0 445.911765 0.003343 1971.580882 0.016652 34.389706 0.000272
std 49154.473122 49728.521553 8325.792791 0.042921 15221.831238 0.077672 2071.908424 0.014075 3039.953445 0.021950 ... 0.090066 0.0 0.0 0.0 184.916416 0.001614 6533.969968 0.083223 21.325753 0.000189
min 54673.000000 1638.000000 750.000000 0.008244 1092.000000 0.010943 83.000000 0.000949 109.000000 0.001246 ... 0.104808 0.0 0.0 0.0 40.000000 0.000246 194.000000 0.003541 1.000000 0.000011
25% 99714.500000 98899.500000 17293.000000 0.148893 29198.750000 0.238181 3626.750000 0.025465 5258.750000 0.037052 ... 0.249538 0.0 0.0 0.0 333.250000 0.002212 832.000000 0.007765 21.000000 0.000121
50% 133033.000000 131676.000000 21735.500000 0.165464 35624.500000 0.276483 4567.500000 0.034827 7006.000000 0.052357 ... 0.310583 0.0 0.0 0.0 431.000000 0.002984 1301.500000 0.008716 32.000000 0.000261
75% 196243.000000 194427.750000 29807.750000 0.178691 47576.000000 0.301631 5817.750000 0.043030 8634.500000 0.065575 ... 0.378799 0.0 0.0 0.0 544.250000 0.003941 1889.750000 0.009977 46.000000 0.000372
max 224965.000000 222151.000000 35785.000000 0.238518 100394.000000 0.501845 11127.000000 0.066026 14961.000000 0.096841 ... 0.541707 0.0 0.0 0.0 1212.000000 0.009597 77134.000000 0.979206 190.000000 0.000990

8 rows × 21 columns


In [28]:
df = df.set_index('Launch Date')

In [29]:
df.head(1)


Out[29]:
Campaign Name Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
Launch Date
2016-08-07 WEEK_143_SUN 87961 86125 963 0.010948 1424 0.016189 168 0.00191 234 ... 0.242991 0 0 0 118 0.001342 1836 0.020873 2 0.000023

1 rows × 22 columns


In [77]:
df_resampled = df.resample('M').sum()

In [78]:
df_resampled.head(1)


Out[78]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
Launch Date
2015-11-30 811268 730711 155854 2.139378 244375 3.36348 32808 0.452906 49860 0.690082 ... 3.471 0 0 0 5074 0.069196 80557 1.025375 472 0.006462

1 rows × 21 columns


In [79]:
df_resampled['Unique Open Rate'] = df_resampled['Unique Opens'] / df_resampled['Sent']
df_resampled['Unique Click Rate'] = df_resampled['Unique Clicks'] / df_resampled['Sent']
df_resampled['Total Open Rate'] = df_resampled['Total Opens'] / df_resampled['Sent']
df_resampled['Total Click Rate'] = df_resampled['Total Clicks'] / df_resampled['Sent']
df_resampled['Total Clicks / Opens'] = df_resampled['Total Clicks'] / df_resampled['Total Opens']
df_resampled['Unique Clicks / Opens'] = df_resampled['Unique Clicks'] / df_resampled['Unique Opens']

In [80]:
df_resampled.head(10)


Out[80]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
Launch Date
2015-11-30 811268 730711 155854 0.192112 244375 0.301226 32808 0.040440 49860 0.061459 ... 0.204031 0 0 0 5074 0.069196 80557 1.025375 472 0.006462
2015-12-31 1329969 1319385 229436 0.172512 383402 0.288279 51305 0.038576 79086 0.059465 ... 0.206274 0 0 0 6247 0.066289 10584 0.111041 515 0.005449
2016-01-31 1329065 1318664 233479 0.175672 392474 0.295301 54993 0.041377 86197 0.064855 ... 0.219625 0 0 0 5387 0.052824 10401 0.101760 447 0.004385
2016-02-29 1485048 1472674 261480 0.176075 437939 0.294899 62982 0.042411 94876 0.063887 ... 0.216642 0 0 0 4216 0.036952 12374 0.108277 455 0.003973
2016-03-31 1787818 1772109 304962 0.170578 511376 0.286034 69525 0.038888 105286 0.058891 ... 0.205888 0 0 0 5448 0.041421 15709 0.123084 573 0.004435
2016-04-30 2173473 2153718 399243 0.183689 676161 0.311097 94647 0.043546 140372 0.064584 ... 0.207601 0 0 0 6885 0.044361 19755 0.127212 680 0.004383
2016-05-31 3121454 3093361 507810 0.162684 866572 0.277618 105763 0.033883 150981 0.048369 ... 0.174228 0 0 0 10875 0.058538 28093 0.152617 671 0.003593
2016-06-30 3916786 3875364 576448 0.147174 911460 0.232706 101044 0.025798 149426 0.038150 ... 0.163941 0 0 0 8772 0.042652 41422 0.200558 592 0.002887
2016-07-31 3250371 3208350 382250 0.117602 654378 0.201324 68172 0.020974 99816 0.030709 ... 0.152536 0 0 0 7270 0.037065 42021 0.232328 262 0.001293
2016-08-31 350269 343050 3875 0.011063 5655 0.016145 595 0.001699 820 0.002341 ... 0.145004 0 0 0 470 0.005368 7219 0.082438 10 0.000114

10 rows × 21 columns


In [81]:
df_resampled.plot(y='Sent')


Out[81]:
<matplotlib.axes._subplots.AxesSubplot at 0x11f73f810>

In [82]:
df_resampled.tail(5)


Out[82]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
Launch Date
2016-04-30 2173473 2153718 399243 0.183689 676161 0.311097 94647 0.043546 140372 0.064584 ... 0.207601 0 0 0 6885 0.044361 19755 0.127212 680 0.004383
2016-05-31 3121454 3093361 507810 0.162684 866572 0.277618 105763 0.033883 150981 0.048369 ... 0.174228 0 0 0 10875 0.058538 28093 0.152617 671 0.003593
2016-06-30 3916786 3875364 576448 0.147174 911460 0.232706 101044 0.025798 149426 0.038150 ... 0.163941 0 0 0 8772 0.042652 41422 0.200558 592 0.002887
2016-07-31 3250371 3208350 382250 0.117602 654378 0.201324 68172 0.020974 99816 0.030709 ... 0.152536 0 0 0 7270 0.037065 42021 0.232328 262 0.001293
2016-08-31 350269 343050 3875 0.011063 5655 0.016145 595 0.001699 820 0.002341 ... 0.145004 0 0 0 470 0.005368 7219 0.082438 10 0.000114

5 rows × 21 columns


In [83]:
df_resampled = df_resampled[:-2]

In [84]:
df_resampled.plot(y=['Unique Open Rate','Sent'],subplots=True,figsize=(8,10))


Out[84]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x120191c50>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x1202d4c50>], dtype=object)

In [85]:
df_resampled.plot(y='Unique Clicks / Opens')


Out[85]:
<matplotlib.axes._subplots.AxesSubplot at 0x12037e7d0>

In [113]:
df_resampled['Unsubscribe Rate'] = df_resampled['Unsubscribes'] / df_resampled['Sent']

In [62]:
df_resampled.plot(y='Unsubscribe Rate')


Out[62]:
<matplotlib.axes._subplots.AxesSubplot at 0x11d2705d0>

In [63]:
df_resampled.plot(y='Sent')


Out[63]:
<matplotlib.axes._subplots.AxesSubplot at 0x11d427090>

In [64]:
df_resampled.plot(y='Unique Clicks')


Out[64]:
<matplotlib.axes._subplots.AxesSubplot at 0x11d46e1d0>

In [86]:
df_resampled['Total Click Rate']


Out[86]:
Launch Date
2015-11-30    0.061459
2015-12-31    0.059465
2016-01-31    0.064855
2016-02-29    0.063887
2016-03-31    0.058891
2016-04-30    0.064584
2016-05-31    0.048369
2016-06-30    0.038150
Freq: M, Name: Total Click Rate, dtype: float64

In [87]:
df_resampled['Total Open Rate']


Out[87]:
Launch Date
2015-11-30    0.301226
2015-12-31    0.288279
2016-01-31    0.295301
2016-02-29    0.294899
2016-03-31    0.286034
2016-04-30    0.311097
2016-05-31    0.277618
2016-06-30    0.232706
Freq: M, Name: Total Open Rate, dtype: float64

In [89]:
df.describe()


Out[89]:
Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks Total Click Rate ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
count 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000 ... 136.000000 136.0 136.0 136.0 136.000000 136.000000 136.000000 136.000000 136.000000 136.000000
mean 143790.595588 141819.014706 22462.036765 0.157925 37380.823529 0.262236 4719.367647 0.034038 7034.705882 0.051110 ... 0.313497 0.0 0.0 0.0 445.911765 0.003343 1971.580882 0.016652 34.389706 0.000272
std 49154.473122 49728.521553 8325.792791 0.042921 15221.831238 0.077672 2071.908424 0.014075 3039.953445 0.021950 ... 0.090066 0.0 0.0 0.0 184.916416 0.001614 6533.969968 0.083223 21.325753 0.000189
min 54673.000000 1638.000000 750.000000 0.008244 1092.000000 0.010943 83.000000 0.000949 109.000000 0.001246 ... 0.104808 0.0 0.0 0.0 40.000000 0.000246 194.000000 0.003541 1.000000 0.000011
25% 99714.500000 98899.500000 17293.000000 0.148893 29198.750000 0.238181 3626.750000 0.025465 5258.750000 0.037052 ... 0.249538 0.0 0.0 0.0 333.250000 0.002212 832.000000 0.007765 21.000000 0.000121
50% 133033.000000 131676.000000 21735.500000 0.165464 35624.500000 0.276483 4567.500000 0.034827 7006.000000 0.052357 ... 0.310583 0.0 0.0 0.0 431.000000 0.002984 1301.500000 0.008716 32.000000 0.000261
75% 196243.000000 194427.750000 29807.750000 0.178691 47576.000000 0.301631 5817.750000 0.043030 8634.500000 0.065575 ... 0.378799 0.0 0.0 0.0 544.250000 0.003941 1889.750000 0.009977 46.000000 0.000372
max 224965.000000 222151.000000 35785.000000 0.238518 100394.000000 0.501845 11127.000000 0.066026 14961.000000 0.096841 ... 0.541707 0.0 0.0 0.0 1212.000000 0.009597 77134.000000 0.979206 190.000000 0.000990

8 rows × 21 columns


In [95]:
df[df['Total Open Rate']<.12]


Out[95]:
Campaign Name Sent Delivered Unique Opens Unique Open Rate Total Opens Total Open Rate Unique Clicks Unique Click Rate Total Clicks ... Total Clicks / Opens Purchases Revenue Revenue / Mille Unsubscribes Unsubscribe Rate Bounces Bounce Rate Spams Spam Rate
Launch Date
2016-08-07 WEEK_143_SUN 87961 86125 963 0.010948 1424 0.016189 168 0.001910 234 ... 0.242991 0 0 0 118 0.001342 1836 0.020873 2 0.000023
2016-08-04 WEEK_143_THURS 87384 85544 1312 0.015014 1890 0.021629 137 0.001568 191 ... 0.145579 0 0 0 157 0.001797 1840 0.021056 2 0.000023
2016-08-03 WEEK_143_WED 87439 85654 750 0.008577 1092 0.012489 121 0.001384 169 ... 0.225333 0 0 0 93 0.001064 1785 0.020414 2 0.000023
2016-08-02 WEEK_143_TUES 87485 85727 850 0.009716 1249 0.014277 169 0.001932 226 ... 0.265882 0 0 0 102 0.001166 1758 0.020095 4 0.000046
2016-07-31 WEEK_142_SUN 87601 85724 936 0.010685 1369 0.015628 189 0.002158 260 ... 0.277778 0 0 0 162 0.001849 1877 0.021427 3 0.000034
2016-07-28 WEEK_142_THURS 87474 85705 1040 0.011889 1489 0.017022 83 0.000949 109 ... 0.104808 0 0 0 192 0.002195 1769 0.020223 1 0.000011
2016-07-27 WEEK_142_WED 108558 106624 895 0.008244 1188 0.010943 205 0.001888 271 ... 0.302793 0 0 0 142 0.001308 1934 0.017815 6 0.000055
2016-07-26 WEEK_142_TUES 151189 148936 6281 0.041544 9460 0.062571 1004 0.006641 1470 ... 0.234039 0 0 0 262 0.001733 2253 0.014902 18 0.000119
2016-07-24 Campaign created on 7/22/2016 4:05:10 PM 176883 174549 8820 0.049863 13125 0.074202 1077 0.006089 1486 ... 0.168481 0 0 0 334 0.001888 2334 0.013195 9 0.000051

9 rows × 22 columns


In [97]:
subs = pd.read_csv('~/Downloads/fatherly-subscribers.csv',index_col=False)

In [98]:
subs.head(1)


Out[98]:
email signupDate
0 pathazfire@gmail.com 2015-11-24 22:25:18 +00:00

In [102]:
subs.signupDate = subs.signupDate.apply(lambda x: str(x))
subs.signupDate = subs.signupDate.apply(lambda x: x.split(' ')[0])
subs.signupDate = pd.to_datetime(subs.signupDate)

In [104]:
subs = subs.set_index('signupDate')

In [105]:
subs['count'] = 1
subs_resampled = subs.resample('M').sum()

In [107]:
subs_resampled


Out[107]:
count
signupDate
2015-10-31 84057
2015-11-30 25008
2015-12-31 13437
2016-01-31 20939
2016-02-29 7216
2016-03-31 57925
2016-04-30 39280
2016-05-31 38192
2016-06-30 35768
2016-07-31 19816

In [108]:
subs_resampled.plot()


Out[108]:
<matplotlib.axes._subplots.AxesSubplot at 0x1209ae290>

In [114]:
df_resampled['Unsubscribe Rate'].describe()


Out[114]:
count    8.000000
mean     0.003723
std      0.001269
min      0.002240
25%      0.002995
50%      0.003326
75%      0.004214
max      0.006254
Name: Unsubscribe Rate, dtype: float64

In [ ]: