<jupyter_start><jupyter_text>Scenario 2 Data CreationThis notebook creates datasets to be used in Scenario 2.<jupyter_code>%pylab inline
import pandas as pd
import random
from datetime import datetime, timedelta
import numpy as np
def gen_day(day):
    startdate = datetime(year=2018,month=1,day=1)
    Date = startdate+timedelta(day)
    Date = Date.strftime('%m-%d-%Y')
    
    tweets = random.randint(1,10)
    tweet_likes = round(tweets**(1.3+random.randint(0,300)/1000),0)
    retweets = round((tweets*(random.random() + random.randint(0,3))) + random.randint(0,500),0)
    
    facebook = random.randint(1,6)
    facebook_likes = round(facebook**(2+(random.randint(1,300)/1000)),0)
    facebook_shares = round(facebook*(2+(random.randint(1,3)/5)),0)
    
    instagram = random.randint(2,9)
    instagram_likes = round(instagram + random.randint(85,100)*(np.log10(instagram)),0)
    instagram_likes = random.randint(42,48)*np.log10(instagram) # + 50*instagram 
    
    day = {'Date': Date,
           'Tweets': tweets,
           'Tweet Likes': int(tweet_likes),
           'Retweets': int(retweets),
           'Facebook Posts': facebook,
           'Facebook Likes': int(facebook_likes),
           'Facebook Shares': int(facebook_shares),
           'Instagram Posts': instagram,
           'Instagram Likes': int(instagram_likes)}

    return day
days = []
for i in range(0,365):
    days.append(gen_day(i))
df = pd.DataFrame.from_records(days)
for i in range(2,10):
    m = df[df['Instagram Posts'] == i]['Instagram Likes'].describe().mean()
    ratio = m/i
    print(i)
    print(ratio)
    print(m)
df.plot.scatter('Instagram Posts','Instagram Likes')
df.plot.scatter('Tweets','Tweet Likes')
df.plot.scatter('Facebook Posts','Facebook Likes')
df.to_csv('../Class Files/Scenario 2/Online_Engagement_2018.csv', index=False)
df['Instagram Likes'].describe()
df['Facebook Likes'].describe()
df['Tweet Likes'].describe()
df['Total'] = df['Facebook Posts'] + df['Instagram Posts'] + df['Tweets']
df.Total.describe()
5*3<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16034985422740525, 'fraction_numerical': 0.037900874635568516, 'mean_word_length': 4.19949494949495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '446797', 'license': 'MIT', 'n_tokens_mistral': 787, 'n_tokens_neox': 721, 'n_words': 134, 'path': 'scenario_2_data_viz_modeling.ipynb', 'repo_name': 'DistrictDataLabs/dos-advanced-excel', 'size': '2058'}