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

%matplotlib inline

In [3]:
df = pd.read_csv('~/documents/vinepair/vinepair-posts.csv',parse_dates=True,index_col=None)

In [4]:
df.head(1)


Out[4]:
Post ID Permalink Post Message Type Countries Languages Posted Audience Targeting Lifetime Post Total Reach Lifetime Post organic reach ... Lifetime Average time video viewed Lifetime Organic views to 95% Lifetime Organic views to 95%.1 Lifetime Paid views to 95% Lifetime Paid views to 95%.1 Lifetime Video length Lifetime Organic Video Views Lifetime Organic Video Views.1 Lifetime Paid Video Views Lifetime Paid Video Views.1
0 481722305228597_1169995286401292 https://www.facebook.com/Vinepair/posts/116999... Just try to keep these in your fridge ;) Link NaN NaN 8/20/16 10:00 PM 3880 3880 ... 0 0.0 0.0 0.0 0.0 0 0.0 0.0 0.0 0.0

1 rows × 34 columns


In [34]:
df['targeted'] = [1 if len(x) > 5 else 0 for x in df['Audience Targeting']]

In [36]:
df.targeted[30:55]


Out[36]:
30    0
31    0
32    0
33    0
34    0
35    0
36    0
37    0
38    0
39    0
40    0
41    0
42    1
43    0
44    0
45    0
46    0
47    0
48    0
49    0
50    0
51    0
52    0
53    0
54    0
Name: targeted, dtype: int64

In [37]:
import seaborn as sns

In [46]:
df_pivoted = df[df.Type == 'Link'].pivot_table(values = 'Lifetime Post Total Reach',columns='targeted')

In [47]:
df_pivoted


Out[47]:
targeted
0    7314.244589
1    4170.500000
Name: Lifetime Post Total Reach, dtype: float64

In [ ]: