changed it to build dataset with a few more variables
[babynames-cdsw] / BabyNames.ipynb
index 8e3d040f47649b92776f523466f6a50b9947f28a..8a8247652dce981a2327dc658122c20df6101e9d 100644 (file)
@@ -6,19 +6,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "NAMES_LIST = \"yob2018.txt\"\n",
-    "\n",
-    "boys = {}\n",
-    "girls = {}\n",
-    "\n",
-    "for line in open(NAMES_LIST, 'r').readlines():\n",
-    "    name, gender, count = line.strip().split(\",\")\n",
-    "    count = int(count)\n",
-    "\n",
-    "    if gender == \"F\":\n",
-    "        girls[name.lower()] = count\n",
-    "    elif gender == \"M\":\n",
-    "        boys[name.lower()] = count"
+    "from ssadata import boys, girls"
    ]
   },
   {
@@ -29,7 +17,7 @@
    "source": [
     "for name in boys.keys():\n",
     "    if name == \"mako\":\n",
-    "        print(\"There were \" + str(ssadata.boys[name]) + \" boys named \" + name)"
+    "        print(\"There were \" + str(boys[name]) + \" boys named \" + name)"
    ]
   },
   {
@@ -49,7 +37,7 @@
    "source": [
     "for name in boys.keys():\n",
     "    if name in girls.keys():\n",
-    "        print(name)\n"
+    "        print(name)"
    ]
   },
   {
@@ -67,7 +55,7 @@
    "source": [
     "for name in boys.keys():\n",
     "    if 'king' == name:\n",
-    "        print(name + \" \" + str(ssadata.boys[name]))"
+    "        print(name + \" \" + str(boys[name]))"
    ]
   },
   {
    "source": [
     "for name in girls.keys():\n",
     "    if 'queen' == name:\n",
-    "        print(name + \" \" + str(ssadata.girls[name]))"
+    "        print(name + \" \" + str(girls[name]))"
    ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "## Now practice your new skills.  Here are some examples of questions you might ask. If you think of any other questions that you think it might be interesting to answer then you should also try to answer those as well!\n",
-    "\n",
-    "\n",
-    "Search for your own name. Are there both boys and girls that have your name? Is it more popular for one group than for the other?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "\n",
-    "Are there more boys' names or girls' names? What about for particular first letters? What about for ''every'' first letter?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "What is the longest name in the dataset?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "What is the most common name and how often does it occur?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "What is the least common name and how often does it occur? Does that concern you?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "How many boys and girls are described in the dataset (i.e., how many boys and girls born in 2018 have names given to at least four others)?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "How many boys' names are also girls' names? How many girls' names are also boys' name\n",
-    "s?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "How many names are subsets of other names?"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "\n",
-    "What is the most popular girls' name that is also a boys' name?\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Take a prefix as input and print the number of boys and girls with that prefix (i.e., \"m\" would list babies whose names start with \"m\" and \"ma\" would list babies whose names start with \"ma\", etc).\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": []
   }
  ],
  "metadata": {
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.7.3"
+   "version": "3.9.2"
   }
  },
  "nbformat": 4,

Benjamin Mako Hill || Want to submit a patch?