Skip to content

Commit eed7fce

Browse files
committed
Stack Overflow Survey Analysis
1 parent c6e1e77 commit eed7fce

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Python/StackOverflow-2019/sof-demo.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import csv
2+
from collections import defaultdict, Counter
3+
4+
with open('data/survey_results_public.csv') as f:
5+
csv_reader = csv.DictReader(f)
6+
7+
dev_type_info = {}
8+
9+
for line in csv_reader:
10+
dev_types = line['DevType'].split(';')
11+
12+
for dev_type in dev_types:
13+
dev_type_info.setdefault(dev_type, {
14+
'total': 0,
15+
'language_counter': Counter()
16+
})
17+
18+
languages = line['LanguageWorkedWith'].split(';')
19+
dev_type_info[dev_type]['language_counter'].update(languages)
20+
dev_type_info[dev_type]['total'] += 1
21+
22+
23+
for dev_type, info in dev_type_info.items():
24+
print(dev_type)
25+
26+
for language, value in info['language_counter'].most_common(5):
27+
language_pct = (value / info['total']) * 100
28+
language_pct = round(language_pct, 2)
29+
30+
print(f'\t{language}: {language_pct}%')

0 commit comments

Comments
 (0)