Community Data Science Course (Spring 2023)/Week 3 coding challenges
Baby Names
Baby Names: How many babies were born last year with your name? Are a wider variety of names used for boys or for girls? What are the most popular names used for both boys and girls? This set of coding challenges will use data from the US Social Security Administration on baby names from the last several years to answer these questions and more!
Goals
- Have fun exploring real data on baby names in the US
- Practice manipulating and searching strings
- Practice using dictionaries
- Practice using numbers and doing simple arithmetic
#0 Setup
- Download the following file that contains the project for the week: https://github.com/CommunityDataScienceCollective/babynames-cdsw/archive/refs/heads/master.zip
- Once you have downloaded the file, extract the contents of the file into a folder on your desktop.
- Open the file
BabyNames.ipynb
as a Jupyter notebook and run the first cell to make sure that it works.
The notebook will begin with a cell that says:
from ssadata import boys, girls
This imports the ssadata module which is a special Python module we created for this project that includes only two things:
boys
- A dictionary where the the keys are names of boys and the values are the number of infants born in 2021 who had that particular name.girls
- A dictionary where the the keys are names of boys and the values are the number of infants born in 2021 who had that particular name.
#1 Your own name!
- Search for your own name. Are there both boys and girls that have your name? Is your name more popular for one group than for the other? (Hint: don't use a for loop for this one.)
#2 Every baby counts
- How many boy names and girl names are described in the dataset?
- How many boys and girls (actual babies!) are described in the dataset?
#3 A sense of what's common
- What is the most common name for each gender in 2021?
- What is the least common name?
- How often do the least common names occur? (Does your answer to this question bother you? Why?)
#4 She wasn't long for this dataset
- What is the longest name in the dataset? How many boys/girls names are exactly that length? What's going on?
#5 Initials to spreadsheets
- Make a dictionary
girl_initials
that says, for each letter of the alphabet (a-z), how many unique girl names begin with that letter. - Do the same for boy names to make
boy_initials
. - Create a "tab separated values" (TSV) file that reports the data in
girl_initials
. Be sure to include a descriptive header columns! You will probably want the file to end with.tsv
so that your computer knows it's a TSV file. - Now do the same for
boy_initials
(be sure to save it into a different file!) - Once you've done this, load up the two files into Google Sheets or Excel.
- For every letter, be ready to tell if there are more boys names or girls names.
- Play around with graphing and see if you can build some instructive graph that shows us something.
Note: Obviously, you won't be able to include your Google Sheet result into your notebook. Instead, please put it online somewhere (e.g., in Google Drive, or OneDrive, or Dropbox or similar) create a link for sharing that doesn't requiring signing in, and put that link into your notebook so we can click through and look at it!
#6 Concentration in names
- What percentage of boys have one of the 10 most popular boys names? What percentage of girls have one of the 10 most popular girls names?
- Take the top 10% most popular boys names. How many girl were given that name? Take the top 10% most popular girls names. How many boys have that name?
#7 Something extra
- Discover at least one fact about the names that is not listed above! Include the code, and a description of your observation written in English text, into your notebook.
#8 Thinking about this dataset
What are some questions you have about this dataset and it was collected or created? What is at least two challenges that people creating this dataset must have faced? How did they resolve them? What are some assumptions they faced?