Skip to content

Instantly share code, notes, and snippets.

@AnupJoseph
Created October 31, 2022 14:37
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/c429213852419dd09be6a9c932f28989 to your computer and use it in GitHub Desktop.
Save AnupJoseph/c429213852419dd09be6a9c932f28989 to your computer and use it in GitHub Desktop.
Gadfly.with_theme(:dark) do
# Subset the data with only rows I need
gender,age = names(dataset)[3],names(dataset)[2]
age_with_gender_data = dataset[!,2:3]
# grouby age and gender and then count
age_and_gender_counts = combine(
groupby(
age_with_gender_data,[gender,age])
, nrow => :n
)
# Sort the results by age
sort!(age_and_gender_counts,age)
age_gender_plot = plot(
age_and_gender_counts,
x=age,
y=:n,
color=gender,
style(bar_spacing=2mm),
Guide.ylabel("Frequency"),
Geom.bar
)
# draw(SVG("kaggle_age_gender_plot.svg"),age_gender_plot)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment