-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktopsRelease.py
135 lines (127 loc) · 3.9 KB
/
desktopsRelease.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import pandas as pd
speakers = pd.read_csv("./DesktopMaster.csv", names = ["modelNumber", "idNumber"])
laptopsFull = pd.DataFrame()
bestBuy = pd.read_csv("./BestBuy/BestBuyDesktops.csv")
print bestBuy.columns.values
bestBuy["name"] = "bestbuy"
bestBuy.set_index("ID", inplace=True)
print bestBuy.head()
print bestBuy.shape
amazon = pd.read_csv("./Amazon/AmazonDesktop.csv")
print amazon.columns.values
amazon.columns = ["ID", "Name", "Price", "Link", "Images", "ModelNumber"]
amazon["name"] = "amazon"
print amazon.columns.values
print amazon.shape
newEgg = pd.read_csv("./newEgg/newEggDesktops.csv")
print newEgg.columns.values
newEgg["name"] = "newEgg"
newEgg["ModelNumber"] = "none"
print newEgg.shape
snapDeal = pd.read_csv("./SnapDeal/snapdealDesktops.csv")
print snapDeal.columns.values
snapDeal["name"] = "snapdeal"
print snapDeal.shape
source = pd.read_csv("./Source/SourceDesktops.csv")
print source.columns.values
source["name"] = "source"
print source.shape
staples = pd.read_csv("./Staples/StaplesDesktops.csv")
print staples.columns.values
staples.columns = ["ID", "Image", "ModelNumber", "Name", "Price", "Link"]
staples["name"] = "staples"
# print staples.head
# print staples.shape
walmart = pd.read_csv("./Walmart/walmartDesktops.csv")
print walmart.columns.values
walmart["name"] = "walmart"
print walmart.shape
rating = [];
for j,row in speakers.iterrows():
modelNumber = row[0]
idNumbers = row[1]
idNumbers = idNumbers.replace("[", "")
idNumbers = idNumbers.replace("]", "")
idNumbers = idNumbers.replace("'", "")
idNumbers = idNumbers.replace("L", "")
list = idNumbers.split(",")
print list
print len(list)
i = 0
ratingDict = {}
ratingDict['snapdeal'] = 0
ratingDict['bestbuy'] = 0
ratingDict['amazon'] = 0
ratingDict['staples'] = 0
ratingDict['source'] = 0
ratingDict['walmart'] = 0
ratingDict['newEgg'] = 0
ratingDict['flipkart'] = 0
while (i < len(list)):
print list[i]
if (list[i].strip() == 'snapdeal'):
ratingDict['snapdeal'] += 1
i += 1
row = snapDeal.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'bestbuy'):
ratingDict['bestbuy'] += 1
i += 1
row = bestBuy.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'amazon'):
ratingDict['amazon'] += 1
i += 1
row = amazon.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'newEgg'):
ratingDict['newEgg'] += 1
i += 1
#row = newEgg.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'source'):
ratingDict['source'] += 1
i += 1
row = source.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'staples'):
ratingDict['staples'] += 1
i += 1
row = staples.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'walmart'):
ratingDict['walmart'] += 1
i += 1
#row = walmart.loc[long(list[i])]
i += 1
continue
if (list[i].strip() == 'flipkart'):
ratingDict['flipkart'] += 1
i += 1
# row = walmart.loc[long(list[i])]
i += 1
continue
ratingCount = 0
enteredCount = 0
foundOthers = False
for key in ratingDict:
if (ratingDict[key] >= 1):
enteredCount += ratingDict[key]
ratingCount += 1
if enteredCount > 1:
if ratingCount == 1:
rating.append(2)
else:
rating.append(3)
else:
rating.append(1)
speakers["Rating"] = rating
print speakers["Rating"].value_counts()
print speakers.head
speakers.to_csv("DesktopMaster.csv",index=False, encoding='utf-8')