-
-
Save fchollet/06004470545626628485eb6122826826 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
groups = { | |
"TensorFlow/Keras": ("Keras", "TensorFlow"), | |
"PyTorch/PyTorch Lightning/Fast.ai": ("PyTorch", "PyTorch Lightning", "Fast.ai"), | |
} | |
counts = {name: 0 for name in groups} | |
total = 0 | |
answer_indices = [] | |
with open("kaggle_survey_2022_responses.csv", newline="\n") as f: | |
reader = csv.reader(f, delimiter=",", quotechar='"') | |
for row_i, row in enumerate(reader): | |
if row_i == 0: | |
for col_i in range(1, 16): | |
answer_indices.append(row.index(f"Q17_{col_i}")) | |
if row_i > 1: | |
use_group = {name: False for name in groups} | |
use_any = False | |
for answer_i in answer_indices: | |
answer = row[answer_i].strip() | |
if answer and answer != "None": | |
use_any = True | |
else: | |
continue | |
use_other = True | |
for name, group in groups.items(): | |
if answer in group: | |
use_group[name] = True | |
use_other = False | |
if use_other: | |
if answer not in counts: | |
counts[answer] = 0 | |
counts[answer] += 1 | |
for name in use_group: | |
if use_group[name]: | |
counts[name] += 1 | |
if use_any: | |
total += 1 | |
for k, v in sorted(counts.items(), key=lambda x: -x[1]): | |
print(f"{k}: {100 * v/total :.2f} %") | |
print("-") | |
print(f"N={total}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment