Skip to content

Instantly share code, notes, and snippets.

@AnupJoseph
Created November 6, 2022 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnupJoseph/269962de3b6dd420d734a24487b58c9d to your computer and use it in GitHub Desktop.
Save AnupJoseph/269962de3b6dd420d734a24487b58c9d to your computer and use it in GitHub Desktop.
Gadfly.with_theme(:dark) do
income_col,exp_col =
"What is your current yearly compensation (approximate \$USD)?","For how many years have you been writing code and/or programming?"
income_subset = select(dataset,[income_col,exp_col])
# Clean out all the missing entries as they are way too hard to deal here
filter!(exp_col => x->!ismissing(x),income_subset)
filter!(income_col => x->!ismissing(x),income_subset)
income_exp_counts = combine(
groupby(income_subset
,[income_col,exp_col]),
nrow=>:num_counts
)
# Create the median income columns
income_exp_counts[!,:median_income] = build_median_income.(income_exp_counts[!,income_col])
sort!(income_exp_counts,:median_income)
income_exp_counts[!,:median_age] = build_median_age.(income_exp_counts[!,exp_col])
sort!(income_exp_counts,:median_age)
# Get a nice color scheme
palettef(c) = get(ColorSchemes.algae,c)
# Plot the graph as a heatmap
income_by_experience = plot(
income_exp_counts,
x=exp_col,
y=income_col,
color=:num_counts,
Geom.rectbin,
Scale.color_continuous(colormap=palettef)
)
# draw(SVG("kaggle_income_by_experience_plot.svg"),income_by_experience)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment