Skip to content

Instantly share code, notes, and snippets.

@dhui
Last active June 17, 2017 06:04
Show Gist options
  • Save dhui/7e56e6f4d3899fddf6aa80b27172179d to your computer and use it in GitHub Desktop.
Save dhui/7e56e6f4d3899fddf6aa80b27172179d to your computer and use it in GitHub Desktop.
"""
Gets stats for salaries by IDE
Inpired by: https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/
Data from: https://drive.google.com/uc?export=download&id=0B0DL28AqnGsrV0VldnVIT1hyb0E
"""
import collections
import csv
def print_stats(ide_salaries):
print "Rank".ljust(5), "IDE".ljust(20), "Median".rjust(10), "Avg".rjust(10), "Cnt".rjust(6)
for rank, (ide, median, avg, cnt) in enumerate(ide_salaries, 1):
print str(rank).ljust(5), str(ide).ljust(20), str(round(median)).rjust(10), str(round(avg)).rjust(10), str(cnt).rjust(6)
def main():
with open("survey_results_public.csv") as f:
d = collections.defaultdict(list)
reader = csv.DictReader(f)
for r in reader:
ides = r["IDE"]
salary = r["Salary"]
# Only consider those who make money
if r["Professional"] != "Professional developer":
continue
if not ides:
continue
if not salary:
continue
if salary == "NA":
continue
salary = float(salary) # some salaries stored in scientific notation
# Will over count here (e.g. same salaries applied to multiple IDEs)
for ide in ides.split(";"):
ide = ide.strip()
d[ide].append(salary)
print "Total # salaries: %s" % sum(len(s) for s in d.itervalues())
print
# Sort for median
for salaries in d.itervalues():
salaries.sort()
ide_salaries = [(i, salaries[len(salaries) / 2], sum(salaries) / len(salaries), len(salaries)) for i, salaries in d.iteritems()]
print "IDEs by median salary"
print_stats(sorted(ide_salaries, key=lambda (i, m, a, c): m, reverse=True))
print
print "IDEs by average salary"
print_stats(sorted(ide_salaries, key=lambda (i, m, a, c): a, reverse=True))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment