Skip to content

Instantly share code, notes, and snippets.

@makyo
Last active August 6, 2017 20:40
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 makyo/13c9fab975f671a4845b6ce6c0eeaba7 to your computer and use it in GitHub Desktop.
Save makyo/13c9fab975f671a4845b6ce6c0eeaba7 to your computer and use it in GitHub Desktop.
Getting cis/non-cis species data
# This is all the data for all species pulled.
cis_noncis = {
u'anthro': {'cis': 59, 'noncis': 18, 'pct-noncis': 23},
u'arcticfox': {'cis': 91, 'noncis': 21, 'pct-noncis': 18},
u'badger': {'cis': 8, 'noncis': 0, 'pct-noncis': 0},
u'bat': {'cis': 28, 'noncis': 10, 'pct-noncis': 26},
u'brownbear': {'cis': 16, 'noncis': 1, 'pct-noncis': 5},
u'cheetah': {'cis': 30, 'noncis': 5, 'pct-noncis': 14},
u'collie': {'cis': 25, 'noncis': 3, 'pct-noncis': 10},
u'cougar': {'cis': 11, 'noncis': 0, 'pct-noncis': 0},
u'coyote': {'cis': 53, 'noncis': 11, 'pct-noncis': 17},
u'deer': {'cis': 61, 'noncis': 20, 'pct-noncis': 24},
u'dinosaur': {'cis': 13, 'noncis': 7, 'pct-noncis': 35},
u'domesticcat': {'cis': 169, 'noncis': 41, 'pct-noncis': 19},
u'dragon': {'cis': 264, 'noncis': 47, 'pct-noncis': 15},
u'fennec': {'cis': 70, 'noncis': 19, 'pct-noncis': 21},
u'feral': {'cis': 10, 'noncis': 1, 'pct-noncis': 9},
u'germanshepherd': {'cis': 48, 'noncis': 6, 'pct-noncis': 11},
u'greyfox': {'cis': 47, 'noncis': 10, 'pct-noncis': 17},
u'griffin': {'cis': 18, 'noncis': 0, 'pct-noncis': 0},
u'grizzlybear': {'cis': 20, 'noncis': 5, 'pct-noncis': 20},
u'horse': {'cis': 28, 'noncis': 3, 'pct-noncis': 9},
u'husky': {'cis': 119, 'noncis': 11, 'pct-noncis': 8},
u'hyaena': {'cis': 41, 'noncis': 7, 'pct-noncis': 14},
u'jackal': {'cis': 27, 'noncis': 3, 'pct-noncis': 10},
u'kangaroo': {'cis': 18, 'noncis': 2, 'pct-noncis': 10},
u'kitsune': {'cis': 44, 'noncis': 23, 'pct-noncis': 34},
u'koala': {'cis': 1, 'noncis': 0, 'pct-noncis': 0},
u'lemur': {'cis': 1, 'noncis': 0, 'pct-noncis': 0},
u'leopard': {'cis': 14, 'noncis': 3, 'pct-noncis': 17},
u'lion': {'cis': 69, 'noncis': 15, 'pct-noncis': 17},
u'lizard': {'cis': 37, 'noncis': 4, 'pct-noncis': 9},
u'monkey': {'cis': 1, 'noncis': 3, 'pct-noncis': 75},
u'mouse': {'cis': 16, 'noncis': 4, 'pct-noncis': 20},
u'other': {'cis': 192, 'noncis': 49, 'pct-noncis': 20},
u'otherbear': {'cis': 16, 'noncis': 3, 'pct-noncis': 15},
u'otherbird': {'cis': 25, 'noncis': 8, 'pct-noncis': 24},
u'othercanine': {'cis': 57, 'noncis': 15, 'pct-noncis': 20},
u'otherdog': {'cis': 142, 'noncis': 41, 'pct-noncis': 22},
u'otherfeline': {'cis': 98, 'noncis': 18, 'pct-noncis': 15},
u'otherfox': {'cis': 126, 'noncis': 27, 'pct-noncis': 17},
u'othermarsupial': {'cis': 11, 'noncis': 5, 'pct-noncis': 31},
u'othermustelid': {'cis': 30, 'noncis': 2, 'pct-noncis': 6},
u'othermusteloid': {'cis': 5, 'noncis': 2, 'pct-noncis': 28},
u'otherprimate': {'cis': 1, 'noncis': 0, 'pct-noncis': 0},
u'otherreptile': {'cis': 17, 'noncis': 4, 'pct-noncis': 19},
u'otherungulate': {'cis': 35, 'noncis': 6, 'pct-noncis': 14},
u'pandabear': {'cis': 8, 'noncis': 2, 'pct-noncis': 20},
u'panther': {'cis': 18, 'noncis': 6, 'pct-noncis': 25},
u'polarbear': {'cis': 11, 'noncis': 0, 'pct-noncis': 0},
u'polymorphic': {'cis': 5, 'noncis': 4, 'pct-noncis': 44},
u'rabbit': {'cis': 74, 'noncis': 16, 'pct-noncis': 17},
u'raccoon': {'cis': 61, 'noncis': 9, 'pct-noncis': 12},
u'raptor': {'cis': 20, 'noncis': 4, 'pct-noncis': 16},
u'rat': {'cis': 13, 'noncis': 6, 'pct-noncis': 31},
u'raven': {'cis': 17, 'noncis': 6, 'pct-noncis': 26},
u'redfox': {'cis': 312, 'noncis': 43, 'pct-noncis': 12},
u'redpanda': {'cis': 38, 'noncis': 10, 'pct-noncis': 20},
u'riverotter': {'cis': 48, 'noncis': 7, 'pct-noncis': 12},
u'seaotter': {'cis': 7, 'noncis': 2, 'pct-noncis': 22},
u'skunk': {'cis': 18, 'noncis': 2, 'pct-noncis': 10},
u'snowleopard': {'cis': 58, 'noncis': 15, 'pct-noncis': 20},
u'squirrel': {'cis': 16, 'noncis': 2, 'pct-noncis': 11},
u'taur': {'cis': 2, 'noncis': 0, 'pct-noncis': 0},
u'tiger': {'cis': 91, 'noncis': 16, 'pct-noncis': 14},
u'weasel': {'cis': 8, 'noncis': 2, 'pct-noncis': 20},
u'wolf': {'cis': 807, 'noncis': 143, 'pct-noncis': 15}
}
from etc.furrypoll2016 import models
responses = models.Response.objects
results = []
n = 0
n_with_species = 0
# Loop through all of the data we have, one response at a time.
while True:
# Get a single result from the dataset.
try:
response = responses.next()
except:
break
# Keep track of how many responses we're dealing with.
n += 1
# Respondents can have multiple characters, so loop through them.
main_species = None
for character in response.overview.characters:
# One of the characters may be marked as the primary character. If this
# one is primary, use it, but only if it has a species category. The
# species category is a general category, such as wolf, fox, etc.
# There is also a 'species text' field which contains the specific name
# of the species.
if character.primary_character and \
len(character.species_category) > 0:
main_species = character.species_category[0]
# Keep track of how many responses with species we have
n_with_species += 1
break
# Add a row to the result set. It will contain the respondent's gender
# identity, their gender alignment (cis/non-cis/it's complicated), and
# the species we selected above.
#
# As a note here, the gender questions, as with many others, allow for a
# a set of answers for the respondent to choose from, as well as a free
# text field for individual answers. Responses where the user typed in
# an answer are marked as 'subjective' and discarded here.
results.append([
response.overview.gender_identity.value if \
response.overview.gender_identity and \
not response.overview.gender_identity.subjective else \
None,
response.overview.gender_alignment.value if \
response.overview.gender_alignment and \
not response.overview.gender_alignment.subjective else \
None,
main_species,
])
# Let's set up some initial variables for what we want to find.
cis = 0.0
noncis = 0.0
complicated = 0.0
masculine_cis = 0.0
masculine_noncis = 0.0
masculine_complicated = 0.0
feminine_cis = 0.0
feminine_noncis = 0.0
feminine_complicated = 0.0
species_counts = {}
# Loop through all of our results, one response at a time.
for row in results:
# All fields are required
if row[0] == None or row[1] == None or row[2] is None:
continue
# If the response for gender alignment is 'transgender', collect the gender
# identities in our variables. Do the same below for 'complicated' and
# 'cisgender'.
#
# As a note here, 'transgender' is only the key in the database. The
# question text specifically asked if the respondent was "not cisgender",
# in order to allow for genderqueer, genderfluid, agender, neutrois, etc.
# answers.
if row[1] == 'transgender':
noncis += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_noncis += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_noncis += 1.0
if row[1] == 'complicated':
complicated += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_complicated += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_complicated += 1.0
if row[1] == 'cisgender':
cis += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_cis += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_cis += 1.0
# Add data to our species list. First, check if the respondent's species
# category is already in the list. If not, add an empty representation.
# We want counts of how many of that species are cisgender and how many
# are not cisgender
if row[2] not in species_counts:
species_counts[row[2]] = {'cis': 0.0, 'noncis': 0.0}
# If the respondent chose 'transgender' or 'complicated', add them to the
# non-cisgender count; otherwise, add them to the cisgender count
if row[1] in ['transgender', 'complicated']:
species_counts[row[2]]['noncis'] += 1.0
else:
species_counts[row[2]]['cis'] += 1.0
from etc.furrypoll2016 import models
responses = models.Response.objects
results = []
n = 0
n_with_species = 0
# Loop through all of the data we have, one response at a time.
while True:
# Get a single result from the dataset.
try:
response = responses.next()
except:
break
# Keep track of how many responses we're dealing with.
n += 1
# Respondents can have multiple characters, so loop through them.
main_species = None
for character in response.overview.characters:
# One of the characters may be marked as the primary character. If this
# one is primary, use it, but only if it has a species category. The
# species category is a general category, such as wolf, fox, etc.
# There is also a 'species text' field which contains the specific name
# of the species.
if character.primary_character and \
len(character.species_category) > 0:
main_species = character.species_category[0]
# Keep track of how many responses with species we have
n_with_species += 1
break
# Add a row to the result set. It will contain the respondent's gender
# identity, their gender alignment (cis/non-cis/it's complicated), and
# the species we selected above.
#
# As a note here, the gender questions, as with many others, allow for a
# a set of answers for the respondent to choose from, as well as a free
# text field for individual answers. Responses where the user typed in
# an answer are marked as 'subjective' and discarded here.
results.append([
response.overview.gender_identity.value if \
response.overview.gender_identity and \
not response.overview.gender_identity.subjective else \
None,
response.overview.gender_alignment.value if \
response.overview.gender_alignment and \
not response.overview.gender_alignment.subjective else \
None,
main_species,
])
# Let's set up some initial variables for what we want to find.
cis = 0.0
noncis = 0.0
complicated = 0.0
masculine_cis = 0.0
masculine_noncis = 0.0
masculine_complicated = 0.0
feminine_cis = 0.0
feminine_noncis = 0.0
feminine_complicated = 0.0
species_counts = {}
# Loop through all of our results, one response at a time.
for row in results:
# All fields are required
if row[0] == None or row[1] == None or row[2] is None:
continue
# If the response for gender alignment is 'transgender', collect the gender
# identities in our variables. Do the same below for 'complicated' and
# 'cisgender'.
#
# As a note here, 'transgender' is only the key in the database. The
# question text specifically asked if the respondent was "not cisgender",
# in order to allow for genderqueer, genderfluid, agender, neutrois, etc.
# answers.
if row[1] == 'transgender':
noncis += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_noncis += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_noncis += 1.0
if row[1] == 'complicated':
complicated += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_complicated += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_complicated += 1.0
if row[1] == 'cisgender':
cis += 1.0
if row[0] in ['male', 'mostly_male']:
masculine_cis += 1.0
elif row[0] in ['female', 'mostly_female']:
feminine_cis += 1.0
# Add data to our species list. First, check if the respondent's species
# category is already in the list. If not, add an empty representation.
# We want counts of how many of that species are cisgender and how many
# are not cisgender
if row[2] not in species_counts:
species_counts[row[2]] = {'cis': 0.0, 'noncis': 0.0}
# If the respondent chose 'transgender' or 'complicated', add them to the
# non-cisgender count; otherwise, add them to the cisgender count
if row[1] in ['transgender', 'complicated']:
species_counts[row[2]]['noncis'] += 1.0
else:
species_counts[row[2]]['cis'] += 1.0
# Print some basic numbers. These will help give us an overview of the dataset
# before it's broken down into species.
# First, print the number of respondents who are cis, non-cis, and complicated
# and how many per category identify as masculine and feminine.
print ' cis: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
cis, masculine_cis, feminine_cis)
print ' noncis: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
noncis, masculine_noncis, feminine_noncis)
print 'complicated: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
complicated, masculine_complicated, feminine_complicated)
# Print 80 equal signs as a border between rows
print '='*80
# Next, print the same information as above, only broken down into percentages.
print ' cis: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
cis / len(results),
masculine_cis / cis,
feminine_cis / cis)
print ' noncis: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
noncis / len(results),
masculine_noncis / noncis,
feminine_noncis / noncis)
print 'complicated: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
complicated / len(results),
masculine_complicated / complicated,
feminine_complicated / complicated)
print '='*80
# Finally, let's get the data at the heart of our question.
#
# Start with some empty variables for our most and least non-cisgender species.
most_noncis = {'species': None, 'pct': 0.0, 'noncis': 0.0, 'cis': 0.0}
least_noncis = {'species': None, 'pct': 1.0, 'noncis': 0.0, 'cis': 0.0}
# Loop through the all of the species we have
for species, res in species_counts.items():
# Find out the percentage of the species that is non-cisgender
# (number of non-cis respondents divided by the total number of
# respondents), and store that number in that species' result for now.
pct_noncis = res['noncis'] / (res['noncis'] + res['cis'])
species_counts[species]['pct-noncis'] = pct_noncis
# Skip species with less than 100% respondents. Small-number statistics may
# lead us to incorrect assumptions.
if res['cis'] + res['noncis'] < 100:
continue
# If this species percent-non-cisgender is greater than the current tally
# for the most non-cisgender species, replace that tally with the current
# species.
if pct_noncis > most_noncis['pct']:
most_noncis = {
'species': species,
'pct': pct_noncis,
'noncis': res['noncis'],
'cis': res['cis'],
}
# If this species percent-non-cisgender is less than the current tally
# for the least non-cisgender species, replace that tally with the current
# species.
if pct_noncis < least_noncis['pct']:
least_noncis = {
'species': species,
'pct': pct_noncis,
'noncis': res['noncis'],
'cis': res['cis'],
}
# Finally, print out the species and percentages for most and least
# non-cisgender species
print ('most non-cis species: {:<10} at {:>2.2%} non-cisgender '
'({:5.0f} non-cis vs {:5.0f} cis)').format(
most_noncis['species'],
most_noncis['pct'],
most_noncis['noncis'],
most_noncis['cis'])
print (' most cis species: {:<10} at {:>2.2%} non-cisgender '
'({:5.0f} non-cis vs {:5.0f} cis)').format(
least_noncis['species'],
least_noncis['pct'],
least_noncis['noncis'],
least_noncis['cis'])
print '='*80
# Print the number of responses.
print "n = {}".format(n)
print "n (with species) = {}".format(n_with_species)
print '='*80
# Print the number of responses.
print "n = {}".format(n)
print "n (with species) = {}".format(n_with_species)
# Finally, print out the species and percentages for most and least
# non-cisgender species
print ('most non-cis species: {:<10} at {:>2.2%} non-cisgender '
'({:5.0f} non-cis vs {:5.0f} cis)').format(
most_noncis['species'],
most_noncis['pct'],
most_noncis['noncis'],
most_noncis['cis'])
print (' most cis species: {:<10} at {:>2.2%} non-cisgender '
'({:5.0f} non-cis vs {:5.0f} cis)').format(
least_noncis['species'],
least_noncis['pct'],
least_noncis['noncis'],
least_noncis['cis'])
# Print some basic numbers. These will help give us an overview of the dataset
# before it's broken down into species.
# First, print the number of respondents who are cis, non-cis, and complicated
# and how many per category identify as masculine and feminine.
print ' cis: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
cis, masculine_cis, feminine_cis)
print ' noncis: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
noncis, masculine_noncis, feminine_noncis)
print 'complicated: {:5.0f} (masculine: {:5.0f}, feminine: {:5.0f})'.format(
complicated, masculine_complicated, feminine_complicated)
# Print 80 equal signs as a border between rows
print '='*80
# Next, print the same information as above, only broken down into percentages.
print ' cis: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
cis / len(results),
masculine_cis / cis,
feminine_cis / cis)
print ' noncis: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
noncis / len(results),
masculine_noncis / noncis,
feminine_noncis / noncis)
print 'complicated: {:2.2%} (masculine: {:2.2%}, feminine: {:2.2%})'.format(
complicated / len(results),
masculine_complicated / complicated,
feminine_complicated / complicated)
cis: 3926 (masculine: 3301, feminine: 581)
noncis: 453 (masculine: 150, feminine: 135)
complicated: 340 (masculine: 114, feminine: 45)
================================================================================
cis: 72.02% (masculine: 84.08%, feminine: 14.80%)
noncis: 8.31% (masculine: 33.11%, feminine: 29.80%)
complicated: 6.24% (masculine: 33.53%, feminine: 13.24%)
================================================================================
most non-cis species: otherdog at 22.04% non-cisgender ( 41 non-cis vs 145 cis)
most cis species: husky at 8.27% non-cisgender ( 11 non-cis vs 122 cis)
================================================================================
n = 5451
n (with species) = 4848
# Finally, let's get the data at the heart of our question.
#
# Start with some empty variables for our most and least non-cisgender species.
most_noncis = {'species': None, 'pct': 0.0, 'noncis': 0.0, 'cis': 0.0}
least_noncis = {'species': None, 'pct': 1.0, 'noncis': 0.0, 'cis': 0.0}
# Loop through the all of the species we have
for species, res in species_counts.items():
# Find out the percentage of the species that is non-cisgender
# (number of non-cis respondents divided by the total number of
# respondents), and store that number in that species' result for now.
pct_noncis = res['noncis'] / (res['noncis'] + res['cis'])
species_counts[species]['pct-noncis'] = pct_noncis
# Skip species with less than 100% respondents. Small-number statistics may
# lead us to incorrect assumptions.
if res['cis'] + res['noncis'] < 100:
continue
# If this species percent-non-cisgender is greater than the current tally
# for the most non-cisgender species, replace that tally with the current
# species.
if pct_noncis > most_noncis['pct']:
most_noncis = {
'species': species,
'pct': pct_noncis,
'noncis': res['noncis'],
'cis': res['cis'],
}
# If this species percent-non-cisgender is less than the current tally
# for the least non-cisgender species, replace that tally with the current
# species.
if pct_noncis < least_noncis['pct']:
least_noncis = {
'species': species,
'pct': pct_noncis,
'noncis': res['noncis'],
'cis': res['cis'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment