Skip to content

Instantly share code, notes, and snippets.

@ascott
Last active February 8, 2017 23:14
Show Gist options
  • Save ascott/b154195a4359a6a14df2 to your computer and use it in GitHub Desktop.
Save ascott/b154195a4359a6a14df2 to your computer and use it in GitHub Desktop.
percentage of female artists at the Tate Modern.
# tate-modern-artists.csv can be retrieved here:
# https://raw.githubusercontent.com/tategallery/collection/master/artist_data.csv
require('CSV')
male = 0
female = 0
CSV.foreach("tate-modern-artists.csv") do |row|
if row[2] == "Male"
male = male + 1
elsif row[2] == "Female"
female = female + 1
end
end
total = male + female
percentage_female = (female.to_f / total.to_f) * 100
puts "male = #{male}"
puts "female = #{female}"
puts "percentage_female = #{percentage_female}"
# output
# male = 2895
# female = 521
# percentage_female = 15.251756440281032
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment