In [1]:
import random
from datetime import datetime
import numpy as np

#year = random.randint(1950, 2000)
#month = random.randint(1, 12)
year = 2017
month = 12

# Generate 300 random timestamps and users
n_events = 300
action_dic = {0:'send',1:'accept',2:'reject'}


events=[]
for i in range(n_events): 
    day = random.randint(1, 24)
    # add a few null values
    #if i & 3 == 2 :
    #    user = np.nan
    #else:
    
    # One sent event
    userid = int(random.randint(1,10))
    timestamp = datetime(year, month, day).timestamp()
    action = 'send'
    events.append([timestamp,userid,action])
    
    # One random accept or reject after random number of days:
    days_to_answer = random.randint(1, 4)
    day = day + days_to_answer
    timestamp = datetime(year, month, day).timestamp()
    action=action_dic[random.randint(1,2)]
    events.append([timestamp,userid,action])

    

#>>> from datetime import datetime
#>>> datetime.fromtimestamp(1172969203.1)
#datetime.datetime(2007, 3, 4, 0, 46, 43, 100000)

In [2]:
import numpy as np
import pandas as pd
# numpy array to df

events = np.array(events)
columns = ['timestamp','userid','action']
df = pd.DataFrame(events,columns=columns)
df.head(10)


Out[2]:
timestamp userid action
0 1513756800.0 6 send
1 1514016000.0 6 reject
2 1513238400.0 1 send
3 1513324800.0 1 accept
4 1513497600.0 2 send
5 1513584000.0 2 accept
6 1514102400.0 4 send
7 1514361600.0 4 accept
8 1512115200.0 4 send
9 1512201600.0 4 reject

In [3]:
df.to_csv('actions.csv')

In [ ]:


In [ ]: