Template for Creating Test Data

In [3]:
social()
Out[3]:
submit to reddit

This template should give you enough background code to manipulate to your liking.

In [14]:
import numpy.random as npr
import numpy as np
import pandas as pd

from pandas import DataFrame, date_range
from datetime import datetime, timedelta
In [15]:
np.random.seed(111)

# Function to generate test data
def CreateDataSet(Number=1):
    
    Output = []
    
    for i in range(Number):
        
        # Create a date range with hour frequency
        date = date_range(start='10/1/2012', end='10/31/2012', freq='H')
        
        # Create long lat data
        laty = npr.normal(4815862, 5000,size=len(date))
        longx = npr.normal(687993, 5000,size=len(date))
        
        # status of interest
        status = [0,1]
        
        # Make a random list of statuses
        random_status = [status[npr.randint(low=0,high=len(status))] for i in range(len(date))]
        
        # user pool
        user = ['sally','derik','james','bob','ryan','chris']
        
        # Make a random list of users 
        random_user = [user[npr.randint(low=0,high=len(user))] for i in range(len(date))]
    
        Output.extend(zip(random_user, random_status, date, longx, laty))
        
    return pd.DataFrame(Output, columns = ['user', 'status', 'date', 'long', 'lat'])
In [16]:
# Generate data, and specify how much you want
data = CreateDataSet(2)
data.head()
Out[16]:
user status date long lat
0 ryan 0 2012-10-01 00:00:00 692823.716714 4810192.808328
1 ryan 1 2012-10-01 01:00:00 679549.965772 4817783.595967
2 bob 0 2012-10-01 02:00:00 686339.324152 4823344.768882
3 ryan 0 2012-10-01 03:00:00 677609.798732 4814085.088514
4 sally 1 2012-10-01 04:00:00 689556.379975 4811924.332295

5 rows × 5 columns

In [1]:
from IPython.core.display import HTML


def css_styling():
    styles = open("/users/ryankelly/desktop/custom_notebook.css", "r").read()
    return HTML(styles)
css_styling()
Out[1]:
In [2]:
def social():
    code = """
    <a style='float:left; margin-right:5px;' href="https://twitter.com/share" class="twitter-share-button" data-text="Check this out" data-via="Ryanmdk">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    <a style='float:left; margin-right:5px;' href="https://twitter.com/Ryanmdk" class="twitter-follow-button" data-show-count="false">Follow @Ryanmdk</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    <a style='float:left; margin-right:5px;'target='_parent' href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>
<script src="//platform.linkedin.com/in.js" type="text/javascript">
  lang: en_US
</script>
<script type="IN/Share"></script>
"""
    return HTML(code)
In [ ]: