-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathwork.py
More file actions
51 lines (39 loc) · 1.21 KB
/
work.py
File metadata and controls
51 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pandas as pd
import json
import random
men_content = json.loads(open('men-data.json','r').read())
f_content = json.loads(open('female-data.json','r').read())
obj = {
'a_sex':[],
'dresstype':[],
'image':[],
'price':[],
'arrival':[],
'discount':[]
}
df = pd.DataFrame(obj)
def sanitizePrice(price):
price = price[3:].replace(',','')
return int(price)
for content in men_content:
temp = pd.DataFrame( { 'a_sex' : ['MALE'] ,
'dresstype' :[content['dressType']],
'image' : [content['image']],
'price' : [content['price']],
'arrival':[content['arrival']],
'discount': [content['price']]
})
temp.iloc[0]['discount'] = random.randint( 100, min( 1500, sanitizePrice(content['price'])))
df = df.append(temp, ignore_index = True)
for content in f_content:
temp = pd.DataFrame( { 'a_sex' : ['FEMALE'] ,
'dresstype' :[content['dressType']],
'image' : [content['image']],
'price' : [content['price']],
'arrival':[content['arrival']],
'discount': [content['price']]
})
temp.iloc[0]['discount'] = random.randint(
100, min(1500, sanitizePrice(content['price'])))
df = df.append(temp, ignore_index = True)
df.to_csv('data2.csv')