-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlanguage_data.py
More file actions
55 lines (42 loc) · 1.19 KB
/
Copy pathlanguage_data.py
File metadata and controls
55 lines (42 loc) · 1.19 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
50
51
52
53
54
55
from pymongo import MongoClient
import plotly as py
import plotly.graph_objs as go
client = MongoClient("mongodb+srv://admin:rutgers1@studentinfo-eoita.azure.mongodb.net/test?retryWrites=true")
db = client.test
def gen_learn_pie():
rows = db.inventory.find({})
d = {}
for r in rows:
for l in ['ll1', 'll2', 'll3']:
if(r[l] != 'None'):
if (r[l] in d.keys()):
d[r[l]] = d.get(r[l]) + 1
else:
d[r[l]] = 1
data = [go.Pie(
labels= list(d.keys()),
values= list(d.values())
)]
py.offline.plot({
"data": data,
"layout": go.Layout(title="Languages People Want To Learn")
}, filename='templates/learn-count-pie.html', auto_open=False)
print('plot made')
def gen_share_pie():
rows = db.inventory.find({})
d2 = {}
for r in rows:
for l in ['sl1', 'sl2', 'sl3']:
if(r[l] != 'None'):
if (r[l] in d2.keys()):
d2[r[l]] = d2.get(r[l]) + 1
else:
d2[r[l]] = 1
data = [go.Pie(
labels= list(d2.keys()),
values= list(d2.values())
)]
py.offline.plot({
"data": data,
"layout": go.Layout(title="Languages People Want To Share")
}, filename='templates/share-count-pie.html', auto_open=False)