Last active
February 8, 2017 23:14
-
-
Save ascott/b154195a4359a6a14df2 to your computer and use it in GitHub Desktop.
percentage of female artists at the Tate Modern.
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
# 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