In [1]:
import time
import random

import pandas as pd
import numpy as np


from faker import Factory

In [2]:
fake = Factory.create()

In [3]:
companies = pd.read_csv('label.csv')
companies


Out[3]:
label name
0 Beauty Bobbi Brown Inc.
1 Beauty Dior Beauty
2 Beauty Derma Skincare Centre
3 Beauty KIKO Asia Ltd.
4 Beauty Vichy Laboratories
5 Beauty Colourmix Cosmetics Company Limited
6 Beauty Sa Sa Cosmetic Co. Ltd.
7 Beauty Clinique Laboratories, llc.
8 Beauty Shiseido Company, Limited
9 Beauty Sephora USA, Inc.
10 Beauty MAKE-UP ART COSMETICS.
11 Beauty Clarins.
12 Beauty L'Oreal SA
13 Beauty Laura Mercier Cosmetics.
14 Beauty FANCL International, Inc.
15 Education Memrise Inc.
16 Education Coursera Inc.
17 Education Udacity, Inc.
18 Education Code School LLC.
19 Education edX Inc.
20 Education Open Learning Global Pty Ltd.
21 Education New Oriental Education & Tech Grp
22 Education Chinese TAL Education Group
23 Education Tarena International, Inc.
24 Education Chegg Inc
25 Education 2U, Inc.
26 Education McGraw-Hill Education
27 Education Pearson plc
28 Education China Distance Education Hldgs Ltd
29 Education Udemy, Inc.
... ... ...
120 Entertainment Broadway Cinematheque
121 Entertainment UA Cinema Circuit Limited
122 Entertainment Neway Karaoke Box Limited
123 Entertainment Red MR Limited
124 Entertainment Walt Disney Company
125 Entertainment AMC Entertainment Inc
126 Entertainment Nintendo
127 Entertainment Xbox
128 Entertainment LEGO
129 Entertainment Ocean Park Hong Kong
130 Entertainment Ryze Ultimate Trampoline Park Hong Kong
131 Entertainment Ball Room
132 Entertainment Ikari Area
133 Entertainment VR Arena
134 Entertainment HA cube
135 Clothing American Eagle Outfitters Inc
136 Clothing Holister Co.
137 Clothing Zara
138 Clothing H&M Hennes & Mauritz AB
139 Clothing GAP
140 Clothing Levi Strauss & Co.
141 Clothing G2000
142 Clothing Louis Vuitton
143 Clothing Longchamp
144 Clothing J. Crew
145 Clothing Nike
146 Clothing Adidas
147 Clothing Converse
148 Clothing Superdry
149 Clothing Balenciaga

150 rows × 2 columns


In [9]:
#companies = pd.Series(companies.name.values)

In [8]:
# random.shuffle(companies)

In [8]:
def generate_people(n):
    """ Generates n-people, and returns a data frame.
        Each person has a:
            - id
            - age
            - name
            - address
            
        Two of them may be unexpected:
            - compromised: 0 or 1
            - compromised: if compromised, when
            
        These values get set by other functions."""
#     namePool = np.load('names.npy')
#     ids = [i for i in range(n)]
#     names = [fake.name() for n in range(n)]
#     uuids = [fake.uuid4() for n in range(n)]
#     ages = [random.randint(18, 80) for n in range(n)]
#     addresses = [fake.address().replace('\n', ', ') for n in range(n)]
#     compromised = list(np.zeros(n))
#     compromised_time = list(np.zeros(n))
    #generate names
    names = set()
    while len(names) < n:
        nextName = fake.name()
        if nextName not in names:
            names.add(nextName)
    names = list(names)
    names = np.array(names)
    genders = np.random.choice(['male', 'female'], n)
    ids = np.arange(n)
    ages = [random.randint(18, 50) for _ in range(n)]
    addresses = [fake.address().replace('\n', ', ') for _ in range(n)]
    compromised = list(np.zeros(n))
    compromised_time = list(np.zeros(n))
    df = pd.DataFrame([ids, names, genders, ages, addresses, compromised, compromised_time]).T
    df.columns = ['id', 'name', 'gender', 'age', 'address', 'compromised', 'compromised_time']
    return df

In [12]:
def generate_business(n, fraudster_likelihood=0.01):
    """ Generates n-businesses, and returns a data frame.
        Each person has a:
            - id
            - name
            - address
            
        The one weird one is "frauders_present" which is controlled by the fraudster_likelihood option.
            
        These values get set by other functions."""
    
    ids = [i for i in range(n)]
#     names = list(companies[:n])
    coms = companies.sample(n, replace=True)
    addresses = [fake.address().replace('\n', ', ') for n in range(n)]
    fraudsters = [1 if random.random() < fraudster_likelihood else 0 for n in range(n) ]
    
    df = pd.DataFrame([ids, list(coms['name']), list(coms['label']), addresses]).T
    df.columns = ['id', 'name', 'label', 'address']
    return df

In [15]:
def generate_normal_transactions(people, businesses, max_transactions=40, fraud_likelihood=1, earliest="-30d", latest="now", amin=9, amax=300):
    """ Generates normal transactions. Returns a list."""
    transactions = []
    amounts = []
    companyNameList = []
    companyLabelList = []
    times = []
    users = []
    ageList = []
    genderList = []
    # For each person
    for p in range(len(people)):
        
        person = people.ix[p]
        
        number_of_transactions = random.randint(1, max_transactions)
        
        # Generate soem transactions
        for i in range(number_of_transactions):

            # random time and business
            time = fake.date_time_between(start_date=earliest, end_date=latest, tzinfo=None)
#             time = fake.date_time_this_month()
            business = businesses.sample(1)
            companyName = business['name']
            companyLabel = business['label']
            amount = random.randint(amin, amax) + round(random.random(), 2)

            
            times.append(time)
            companyNameList.append(companyName)
            companyLabelList.append(companyLabel)
            amounts.append(amount)
            users.append(person['name'])
            ageList.append(person.age)
            genderList.append(person.gender)
#             transactions.append(transaction)
    companyList= companies.sample(len(times), replace=True)
    companyNameList = list(companyList['name'])
    companyLabelList = list(companyList['label'])
    
    df = pd.DataFrame([times, users, genderList, ageList, companyNameList, companyLabelList, amounts]).T
    df.columns = ['time', 'name', 'gender' ,'age', 'company name', 'company label', 'amount']
    return df
# generate_normal_transactions(p,b)

In [9]:
def generate_fradulent_transactions(people, businesses, max_transactions=40, user_fraud_detection_likelihood=0.10, latest="+10d", amin=1, amax=3000):
    """ Genereates fradulent transactions. Returns a list."""
    transactions = []
    compromised = people[people.compromised == 1]
    
    for i in range(len(compromised)):
        
        person = compromised.iloc[i]
        earliest = person.compromised_time
        time = fake.date_time_between(start_date=earliest, end_date=latest, tzinfo=None)
#         number_of_transactions = random.randint(5, max_transactions)
        number_of_transactions = max_transactions
        for j in range(number_of_transactions):
    
            def fraud():        

                business = businesses.sample(1)
                amount = random.randint(amin, amax) + round(random.random(), 2)

                transaction = '{time} uuid={uuid} user="{user}" business="{business}" amount={amount} disputed=true'.format(
                    time = time,
                    uuid = person['uuid'],
                    user = person['name'],
                    business = business.name.values[0],
                    amount = amount)

                transactions.append(transaction)

            if j == 1:
                fraud()

            # Each fradulent transaction has +1% chance of being cause from the user
            # Imaginging they are maybe monitoring their transaction history
            # Or happen to be checking one thing or another
            if random.random() < j/100:
                fraud()
            
    return transactions

In [10]:
generate_people(3)


Out[10]:
id name age address compromised compromised_time
0 0 Erin Burton 51 00076 Warren Inlet, North Justinchester, IN 97410 0 0
1 1 Robert Bush 56 528 Duran Port, Ericland, TX 14494-3816 0 0
2 2 Scott Hansen 63 49906 Rivera Rest Suite 699, East Daniel, AS 5... 0 0

In [12]:
generate_business(3)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-44df4dda289a> in <module>()
----> 1 generate_business(3)

<ipython-input-11-1768d55b910a> in generate_business(n, fraudster_likelihood)
     16     fraudsters = [1 if random.random() < fraudster_likelihood else 0 for n in range(n) ]
     17 
---> 18     df = pd.DataFrame([ids, names.name, addresses]).T
     19     df.columns = ['id', 'name', 'address']
     20     return df

/usr/local/lib/python3.6/site-packages/pandas/core/generic.py in __getattr__(self, name)
   3079             if name in self._info_axis:
   3080                 return self[name]
-> 3081             return object.__getattribute__(self, name)
   3082 
   3083     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'name'

In [13]:
p = generate_people(100)
b = generate_business(3000)
b


Out[13]:
id name label address
0 0 Rifle Paper Co. Stationery Unit 0267 Box 4738, DPO AA 00004-9305
1 1 Parker Pen Company Stationery 5644 Rachel Mills, North Sandyfort, WY 55999-3065
2 2 FANCL International, Inc. Beauty USNV Sutton, FPO AA 70850-3992
3 3 McGraw-Hill Education Education 177 Fleming Knolls Suite 937, Geoffreyborough,...
4 4 Chinese TAL Education Group Education 0935 Kimberly Pike, Michaelstad, KY 21575
5 5 Netflix, Inc. Media 12856 Joseph Island, South Joshua, OK 89872
6 6 Balenciaga Clothing USCGC Hall, FPO AA 46989
7 7 Netflix, Inc. Media 674 Henry Passage, Gardnerchester, PR 67737
8 8 Broadway Cinematheque Entertainment 4147 Andrea Rue, Lake Sarah, MD 11984-4336
9 9 J. Crew Clothing 05383 Robertson Lock Suite 509, Nguyenton, PW ...
10 10 Clarins. Beauty 4199 Bethany Freeway, Carlyhaven, NY 89876-0476
11 11 Shiseido Company, Limited Beauty 62465 Christian Hills Apt. 994, East Davidside...
12 12 Café de Coral Dining 064 Barry Road, Sullivanborough, OR 69414
13 13 Citybus Limited Transport 700 Oneal Expressway, Harrisonbury, TX 24317-1515
14 14 Sa Sa Cosmetic Co. Ltd. Beauty 0067 Amy Skyway Apt. 213, Millerstad, VT 70538...
15 15 Hong Kong Dragon Airlines Ltd Transport USS Kelly, FPO AA 17443
16 16 Neway Karaoke Box Limited Entertainment Unit 3861 Box 5262, DPO AP 24658
17 17 VR Arena Entertainment 8760 Deborah Stravenue, Juliehaven, LA 01159
18 18 Liberty Stationery Corp. Stationery 161 Mary Mews, Lake Angelica, TX 95569-7355
19 19 G2000 Clothing Unit 6164 Box 1429, DPO AP 46897-2124
20 20 Tesco PLC Grocery 9359 Cheyenne Haven, Rebeccashire, MS 18285
21 21 Ryze Ultimate Trampoline Park Hong Kong Entertainment PSC 1586, Box 7570, APO AP 19954-0216
22 22 Louis Vuitton Clothing 305 Leslie Canyon Suite 216, Lake Tyler, WI 12880
23 23 Rainbow Department Store Company Limited Grocery PSC 1409, Box 7654, APO AP 60702
24 24 The Dairy Farm Company, Limited Grocery 8287 Dyer Curve Suite 275, Lake Benjaminview, ...
25 25 Udemy, Inc. Education PSC 5336, Box 3428, APO AP 48005-1288
26 26 J. Crew Clothing 6366 Sara Garden Apt. 220, Donaldfurt, NJ 3431...
27 27 Xiami.com Media 6223 Amanda Squares, Westhaven, AK 80593
28 28 Spotify AB Media 9584 Brandon Underpass Apt. 562, New Audreymou...
29 29 Nike Clothing PSC 1292, Box 2093, APO AP 75747-9304
... ... ... ... ...
2970 2970 Code School LLC. Education USS Tran, FPO AE 69030-1549
2971 2971 Tarena International, Inc. Education 4586 Harrell Lodge, North Danielborough, WI 14238
2972 2972 Dior Beauty Beauty 34261 Thomas Track Apt. 653, Tinaborough, MD 4...
2973 2973 HA cube Entertainment 43089 Dalton Squares, East Alyssaland, ND 08344
2974 2974 PILOT CORPORATION Stationery 275 Theresa Knolls, South Bryan, OR 64085
2975 2975 The Dairy Farm Company, Limited Grocery 9276 Amanda Island, Jessicaton, MP 07156-3929
2976 2976 Memrise Inc. Education 6711 West Cliffs, Port Thomas, OH 24506
2977 2977 Sun Life Financial Inc. Investment 42711 Andrew Ridge, North Meghan, MP 39941
2978 2978 Sun Life Financial Inc. Investment PSC 0884, Box 0782, APO AP 90531
2979 2979 Voya Financial, Inc. Investment 561 Moreno Manor Apt. 041, Henryville, VA 2779...
2980 2980 Carrefour SA Grocery 186 Anthony Manor, Bakermouth, IA 34596
2981 2981 Walt Disney Company Entertainment 0182 David Mount Suite 087, Daniellemouth, CT ...
2982 2982 Xiami.com Media 2127 Amber Crossroad, New Joelbury, RI 38726
2983 2983 Pacific Coffee Company Dining 986 Williams Coves, Derrickton, WV 04542
2984 2984 HA cube Entertainment 523 Jenkins Ford, Joelhaven, WV 26193-3040
2985 2985 Uber Transport USNV Walker, FPO AA 89517
2986 2986 Publix Super Markets Grocery 2052 Hector Rapid Apt. 438, Washingtonburgh, N...
2987 2987 McGraw-Hill Education Education USNV Moran, FPO AA 84580
2988 2988 Dior Beauty Beauty 0656 Jones Flat, Hawkinsstad, PA 73585
2989 2989 PILOT CORPORATION Stationery 2558 Robert Mall, West Samuelstad, LA 64925-6151
2990 2990 KKBOX Media 8550 Johnson Street, Joyside, GU 09637-3351
2991 2991 The PNC Financial Services Group, Inc. Investment 812 Audrey Mission, Andreaburgh, NV 19390
2992 2992 Superdry Clothing 819 Rebecca Landing Apt. 442, New Jennifer, SD...
2993 2993 Nike Clothing 915 Garcia Neck Apt. 290, Jonesbury, MH 83434
2994 2994 Air China Airlines Transport 7296 Rios Forks Suite 882, Loribury, DC 15051-...
2995 2995 Converse Clothing 278 George Courts, East Tomstad, OH 52807-5075
2996 2996 Hong Kong Express Airways Limited Transport PSC 0780, Box 2684, APO AE 36278-5969
2997 2997 Din Tai Fung Dining 237 Richardson Lake, Bradleyshire, PW 97352-0681
2998 2998 Broadway Cinematheque Entertainment 3537 Hernandez Springs Suite 347, Smithchester...
2999 2999 SOGO Limited. Grocery 37840 Meyer Throughway, Marcomouth, MA 22015

3000 rows × 4 columns


In [16]:
transactionDf = generate_normal_transactions(p,b)
transactionDf


Out[16]:
time name gender age company name company label amount
0 2017-06-12 08:30:36 Kathryn King female 26 Sa Sa Cosmetic Co. Ltd. Beauty 263.48
1 2017-06-22 04:35:23 Kathryn King female 26 Sizzler Dining 262.65
2 2017-07-03 07:45:55 Kathryn King female 26 Nintendo Entertainment 287.86
3 2017-06-30 09:52:34 Kathryn King female 26 Zara Clothing 89.23
4 2017-06-09 15:30:12 Kathryn King female 26 Pearson plc Education 104.38
5 2017-06-16 12:42:59 Kathryn King female 26 UA Cinema Circuit Limited Entertainment 50.31
6 2017-06-22 00:13:27 Kathryn King female 26 Sephora USA, Inc. Beauty 40.1
7 2017-06-22 07:12:50 Kathryn King female 26 Tim Ho Wan Dining 197.74
8 2017-06-25 21:26:56 Kathryn King female 26 Rainbow Department Store Company Limited Grocery 94.67
9 2017-06-23 22:09:02 Kathryn King female 26 Voya Financial, Inc. Investment 165.27
10 2017-06-27 08:04:20 Kathryn King female 26 Longchamp Clothing 187.36
11 2017-06-12 02:35:57 Kathryn King female 26 L'Oreal SA Beauty 29.54
12 2017-07-05 17:18:49 Kathryn King female 26 Mass Transit Railway (MTR) Transport 169.79
13 2017-07-03 16:09:22 Kathryn King female 26 Parker Pen Company Stationery 50.86
14 2017-06-09 13:18:41 Kathryn King female 26 Udemy, Inc. Education 106.89
15 2017-06-14 04:22:33 Kathryn King female 26 The Kowloon Motor Bus Company Limited Transport 238.05
16 2017-06-18 21:01:31 Kathryn King female 26 Udacity, Inc. Education 108.45
17 2017-06-14 10:57:38 Kathryn King female 26 A.S. Watson Group (Hong Kong) Ltd. Grocery 249.53
18 2017-06-07 17:24:06 Kathryn King female 26 2U, Inc. Education 81.53
19 2017-06-10 06:13:31 Tracy Wilkerson female 36 Mannings. Grocery 132.75
20 2017-06-15 14:21:44 Tracy Wilkerson female 36 Colourmix Cosmetics Company Limited Beauty 300.48
21 2017-07-05 22:23:16 Tracy Wilkerson female 36 Air China Airlines Transport 93.7
22 2017-06-10 04:22:02 Tracy Wilkerson female 36 KIKO Asia Ltd. Beauty 285.06
23 2017-06-27 06:30:12 Tracy Wilkerson female 36 Burger King Dining 199.24
24 2017-07-01 09:24:00 Tracy Wilkerson female 36 Laura Mercier Cosmetics. Beauty 114.03
25 2017-06-15 22:06:22 Tracy Wilkerson female 36 Uber Transport 146.56
26 2017-06-13 22:14:19 Tracy Wilkerson female 36 Best Buy Co Inc Grocery 290.2
27 2017-06-22 17:30:50 Tracy Wilkerson female 36 Louis Vuitton Clothing 243.57
28 2017-06-30 10:38:54 Tracy Wilkerson female 36 Converse Clothing 151.39
29 2017-06-08 04:26:50 Tracy Wilkerson female 36 TCF Financial Corporation Investment 29.33
... ... ... ... ... ... ... ...
2193 2017-06-30 16:14:03 Jason Martinez male 28 Pearson plc Education 244.28
2194 2017-06-17 02:29:34 Jason Martinez male 28 Parker Pen Company Stationery 149.44
2195 2017-06-09 07:57:31 Jason Martinez male 28 Longchamp Clothing 262.6
2196 2017-06-30 22:20:48 Jason Martinez male 28 Liberty Stationery Corp. Stationery 161.36
2197 2017-06-12 11:06:04 Jason Martinez male 28 Shiseido Company, Limited Beauty 178.98
2198 2017-06-07 08:39:30 Jason Martinez male 28 Yadkin Financial Corporation Investment 107.68
2199 2017-06-25 04:58:03 Jason Martinez male 28 Burger King Dining 246.93
2200 2017-06-26 06:12:23 Jason Martinez male 28 Principal Financial Group Inc Investment 231.46
2201 2017-06-19 15:35:18 Jason Martinez male 28 Zara Clothing 211.81
2202 2017-06-08 22:54:53 Jason Martinez male 28 Costco Wholesale Corporation Grocery 225.86
2203 2017-06-28 19:11:05 Jason Martinez male 28 Subway Dining 247.58
2204 2017-06-08 09:49:45 Stephanie Reynolds female 32 Vudu, Inc. Media 225.06
2205 2017-07-05 02:25:37 Stephanie Reynolds female 32 Din Tai Fung Dining 247.2
2206 2017-06-22 18:21:15 Stephanie Reynolds female 32 A.S. Watson Group (Hong Kong) Ltd. Grocery 130.56
2207 2017-06-28 14:58:55 Stephanie Reynolds female 32 HA cube Entertainment 163.83
2208 2017-06-28 03:04:31 Stephanie Reynolds female 32 Peak Tramways Company Limited Transport 283.41
2209 2017-06-26 05:27:48 Stephanie Reynolds female 32 Maped SAS Stationery 88.2
2210 2017-06-14 06:02:26 Stephanie Reynolds female 32 Webster Financial Corporation Investment 191.24
2211 2017-07-02 11:55:44 Stephanie Reynolds female 32 Faber-Castell Stationery 108.65
2212 2017-07-05 06:12:44 Stephanie Reynolds female 32 Balenciaga Clothing 264.47
2213 2017-06-19 06:13:19 Stephanie Reynolds female 32 China Distance Education Hldgs Ltd Education 147.92
2214 2017-06-20 09:50:12 Stephanie Reynolds female 32 Citybus Limited Transport 19.32
2215 2017-06-21 13:28:16 Stephanie Reynolds female 32 Mannings. Grocery 274.92
2216 2017-06-13 20:01:15 Stephanie Reynolds female 32 Spotify AB Media 216.02
2217 2017-06-25 15:28:02 Stephanie Reynolds female 32 Walt Disney Company Entertainment 177.13
2218 2017-06-11 20:45:42 Stephanie Reynolds female 32 HA cube Entertainment 83.83
2219 2017-06-24 20:58:47 Stephanie Reynolds female 32 Pearson plc Education 191.7
2220 2017-06-11 18:16:08 Stephanie Reynolds female 32 Nike Clothing 179.19
2221 2017-06-22 08:47:39 Stephanie Reynolds female 32 ZAIS Financial Corp. Investment 289.62
2222 2017-06-20 13:27:43 Stephanie Reynolds female 32 Synovus Financial Corp. Investment 125.98

2223 rows × 7 columns


In [79]:
np.mean(list(transactionDf.age))
transactionDf = transactionDf[['time','name','age','company name', 'company label', 'amount']]
transactionDf.to_csv('transaction.csv', index=False)

In [80]:
df = pd.read_csv('transaction.csv')
df


Out[80]:
time name age company name company label amount
0 2017-06-14 10:01:38 Jennifer Strickland 50 Shiseido Company, Limited Beauty 206.13
1 2017-07-02 07:20:13 Jennifer Strickland 50 Yoshinoya Dining 200.84
2 2017-06-30 18:11:29 Jennifer Strickland 50 Converse Clothing 188.42
3 2017-06-06 20:59:09 Jennifer Strickland 50 The Dairy Farm Company, Limited Grocery 275.78
4 2017-06-13 02:26:17 Jennifer Strickland 50 Waddell & Reed Financial, Inc. Investment 51.27
5 2017-06-21 06:57:14 Jennifer Strickland 50 Maped SAS Stationery 56.14
6 2017-06-15 22:56:50 Jennifer Strickland 50 Waddell & Reed Financial, Inc. Investment 240.68
7 2017-06-13 09:41:39 Jennifer Strickland 50 Long Win Bus Company Limited Transport 197.07
8 2017-06-20 13:28:07 Jennifer Strickland 50 Sakura Color Products Corporation Stationery 51.86
9 2017-06-09 07:21:32 Jennifer Strickland 50 HA cube Entertainment 124.35
10 2017-06-21 13:31:27 Jennifer Strickland 50 Derma Skincare Centre Beauty 126.00
11 2017-06-23 09:55:13 Jennifer Strickland 50 New World First Bus Services Limited Transport 16.03
12 2017-06-25 08:26:21 Jennifer Strickland 50 Xbox Entertainment 137.61
13 2017-06-22 10:22:37 Jennifer Strickland 50 McGraw-Hill Education Education 245.85
14 2017-06-15 08:50:57 Jennifer Strickland 50 Pearson plc Education 234.29
15 2017-06-14 16:32:38 Jennifer Strickland 50 Societe B I C SA Stationery 104.60
16 2017-06-09 15:39:00 Jennifer Strickland 50 Nintendo Entertainment 195.11
17 2017-06-30 06:29:43 Jennifer Strickland 50 H&M Hennes & Mauritz AB Clothing 206.60
18 2017-06-08 21:43:40 Jennifer Strickland 50 Sephora USA, Inc. Beauty 208.17
19 2017-06-29 23:11:08 Jennifer Strickland 50 3M Company Stationery 212.72
20 2017-06-06 17:08:35 Jennifer Strickland 50 Yoshinoya Dining 45.49
21 2017-06-25 03:01:08 Jennifer Strickland 50 Rainbow Department Store Company Limited Grocery 112.65
22 2017-06-15 04:15:29 Jennifer Strickland 50 City Super Limited Grocery 299.08
23 2017-06-27 13:08:19 Jennifer Strickland 50 Ikari Area Entertainment 162.76
24 2017-07-04 17:52:11 Jennifer Strickland 50 Wal-Mart Stores Inc Grocery 37.47
25 2017-06-10 03:06:25 Jennifer Strickland 50 Webster Financial Corporation Investment 27.00
26 2017-06-28 18:40:06 Jennifer Strickland 50 New Oriental Education & Tech Grp Education 273.95
27 2017-07-01 20:30:44 Jennifer Strickland 50 Superdry Clothing 281.21
28 2017-06-26 18:53:31 Jennifer Strickland 50 FANCL International, Inc. Beauty 225.08
29 2017-06-14 08:16:39 Jennifer Strickland 50 Ikari Area Entertainment 111.45
... ... ... ... ... ... ...
2016 2017-06-26 02:55:05 Reginald Lee 32 Dior Beauty Beauty 63.55
2017 2017-06-13 15:45:33 Reginald Lee 32 McGraw-Hill Education Education 248.55
2018 2017-06-17 11:53:37 Reginald Lee 32 Wing Wah Dining 260.77
2019 2017-06-22 04:22:25 Reginald Lee 32 J. Crew Clothing 26.41
2020 2017-06-27 15:16:45 Reginald Lee 32 iQIYI.COM Media 101.52
2021 2017-06-25 19:20:32 Reginald Lee 32 Liberty Stationery Corp. Stationery 62.75
2022 2017-06-17 20:57:28 Reginald Lee 32 Stifel Financial Corporation Investment 84.47
2023 2017-07-05 08:46:49 Reginald Lee 32 edX Inc. Education 237.93
2024 2017-06-27 02:31:05 Reginald Lee 32 Crackle, Inc. Media 208.93
2025 2017-06-27 20:13:06 Reginald Lee 32 QQ Music Media 147.62
2026 2017-06-25 11:41:44 Reginald Lee 32 Ikari Area Entertainment 110.86
2027 2017-06-29 07:07:24 Reginald Lee 32 The Dairy Farm Company, Limited Grocery 86.13
2028 2017-06-20 00:04:37 Reginald Lee 32 Neway Karaoke Box Limited Entertainment 200.52
2029 2017-06-11 21:46:17 Reginald Lee 32 KFC Dining 149.41
2030 2017-07-02 15:35:32 Reginald Lee 32 SOGO Limited. Grocery 49.76
2031 2017-06-25 14:58:33 Reginald Lee 32 New Oriental Education & Tech Grp Education 124.48
2032 2017-07-05 04:17:01 Reginald Lee 32 Red MR Limited Entertainment 57.59
2033 2017-06-06 18:44:13 Reginald Lee 32 Home Box Office Inc. Media 37.66
2034 2017-06-16 15:54:56 Reginald Lee 32 Sa Sa Cosmetic Co. Ltd. Beauty 290.76
2035 2017-06-30 16:16:37 Reginald Lee 32 Tarena International, Inc. Education 30.53
2036 2017-06-28 02:14:28 Reginald Lee 32 Citybus Limited Transport 262.21
2037 2017-06-11 04:01:11 Reginald Lee 32 Nintendo Entertainment 248.80
2038 2017-06-15 09:46:17 Reginald Lee 32 KFC Dining 77.76
2039 2017-06-23 17:03:10 Reginald Lee 32 RAIT Financial Trust Investment 249.50
2040 2017-06-29 22:41:56 Reginald Lee 32 Rifle Paper Co. Stationery 125.41
2041 2017-06-27 00:11:35 Reginald Lee 32 Walt Disney Company Entertainment 50.92
2042 2017-07-04 09:45:34 Reginald Lee 32 Adidas Clothing 62.26
2043 2017-07-05 23:19:20 Reginald Lee 32 Shiseido Company, Limited Beauty 76.30
2044 2017-06-21 04:35:56 Reginald Lee 32 Pizza Hut Dining 73.11
2045 2017-06-27 10:24:09 Reginald Lee 32 Hong Kong Dragon Airlines Ltd Transport 187.64

2046 rows × 6 columns


In [18]:
len(t) + len(f)


Out[18]:
1927

In [19]:
t.extend(f)
len(t)


Out[19]:
1927

In [20]:
with open('output.log', 'w') as f:
    for line in t:
        f.write(line)
        f.write('\n')

In [21]:
! ls


LICENSE                                credit-card-fraud-data-generator.ipynb
README.md                              output.log
companies.csv                          requirements.txt

In [22]:
! head output.log


2017-07-02 12:17:52 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Emergent Biosolutions, Inc." amount=267.69 disputed=false
2017-07-02 12:18:03 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Blackrock Core Bond Trust" amount=245.13 disputed=false
2017-07-02 12:18:03 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Phillips 66 Partners LP" amount=160.64 disputed=false
2017-07-02 12:17:40 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Kimberly-Clark Corporation" amount=148.37 disputed=false
2017-07-02 12:17:37 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Seaspan Corporation" amount=233.69 disputed=false
2017-07-02 12:17:56 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Time Warner Inc." amount=164.46 disputed=false
2017-07-02 12:18:13 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Flaherty & Crumrine Preferred Income Opportunity Fund Inc" amount=232.47 disputed=false
2017-07-02 12:17:32 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="Stone Energy Corporation" amount=165.0 disputed=false
2017-07-02 12:17:36 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="TELUS Corporation" amount=123.96 disputed=false
2017-07-02 12:17:28 uuid=6a8d3fa6-e47e-4c59-a469-c2a4a4ac4247 user="Lisa Henderson" business="SunCoke Energy, Inc." amount=111.38 disputed=false