From e52c22992ffd424aca3471fcfe4323aabdcca1bd Mon Sep 17 00:00:00 2001 From: msyamkumar <msyamkumar@wisc.edu> Date: Wed, 2 Nov 2022 07:20:44 -0500 Subject: [PATCH] Lecture 24 notebooks --- .../demo_lec_23-checkpoint.ipynb | 623 ------ .../demo_lec_24-checkpoint.ipynb | 756 -------- .../function_references-checkpoint.ipynb | 1006 ---------- ...ction_references_template-checkpoint.ipynb | 974 ---------- ...c_24_comprehensions-Copy1-checkpoint.ipynb | 1035 ---------- .../lec_24_comprehensions-checkpoint.ipynb | 1678 ---------------- ...4_comprehensions_template-checkpoint.ipynb | 739 ------- .../lec-24/cs220_survey_data.csv | 1714 ++++++++++------- .../lec-24/lec_24_comprehensions.ipynb | 255 ++- .../lec_24_comprehensions_template.ipynb | 36 +- 10 files changed, 1176 insertions(+), 7640 deletions(-) delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_23-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_24-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references_template-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-Copy1-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-checkpoint.ipynb delete mode 100644 f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions_template-checkpoint.ipynb diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_23-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_23-checkpoint.ipynb deleted file mode 100644 index db65d17..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_23-checkpoint.ipynb +++ /dev/null @@ -1,623 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1: simple example to demonstrate how to use function references\n", - "## Use PyTutor to go through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def say_hi():\n", - " print(\"Hello there!\")\n", - "\n", - "def say_bye():\n", - " print(\"Wash your hands and stay well, bye!\")\n", - " \n", - "f = say_hi\n", - "f()\n", - "f()\n", - "f = say_bye\n", - "f()\n", - "f()\n", - "f()" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "for i in range(2):\n", - " say_hi()\n", - "\n", - "for i in range(3):\n", - " say_bye()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def call_n_times(f, n):\n", - " for i in range(n):\n", - " f()\n", - "\n", - "call_n_times(say_hi, 2)\n", - "call_n_times(say_bye, 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 2: Apply various transformations to all items on a list" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "L = [\"1\", \"23\", \"456\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Write apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: list object reference, function object\n", - "# b. Output: new list reference to transformed object\n", - "# c. Pseudocode:\n", - "# 1. Initiliaze new empty list for output - we don't want to modify the input list! \n", - "# 2. Process each item in input list\n", - "# 3. Apply the function passed as arugment to 2nd parameter\n", - "# 4. And the transformed item into output list\n", - "# 5. return output list\n", - "\n", - "def apply_to_each(original_L, f):\n", - " new_vals = []\n", - " for val in original_L:\n", - " new_vals.append(f(val))\n", - " return new_vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply int function to list L using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "vals = apply_to_each(L, int)\n", - "vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Write strip_dollar function" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: string value\n", - "# b. Output: transformed string value\n", - "# c. Pseudocode: \n", - "#. 1. Check whether input string begins with $ - what string method do you need here?\n", - "# 2. If so remove it\n", - "\n", - "def strip_dollar(s):\n", - " #Remove the beginning $ sign from string s\n", - " if s.startswith(\"$\"):\n", - " s = s[1:]\n", - " return s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply strip_dollar function and then apply int function" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['1', '23', '456']\n", - "[1, 23, 456]\n" - ] - } - ], - "source": [ - "L = [\"$1\", \"23\", \"$456\"]\n", - "vals = apply_to_each(L, strip_dollar)\n", - "print(vals)\n", - "vals = apply_to_each(vals, int)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply upper method call to the below list L by using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['AAA', 'BBB', 'CCC']\n" - ] - } - ], - "source": [ - "L = [\"aaa\", \"bbb\", \"ccc\"]\n", - "vals = apply_to_each(L, str.upper)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## map function" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "L = [\"1\", \"23\", \"456\"]\n", - "list(map(int, L))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3: Custom sort a list of dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990, \"speed\": 250},\n", - "]" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'A', 'year': 2000, 'speed': 150}" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'B', 'year': 1980, 'speed': 100}" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[1]" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'<' not supported between instances of 'dict' and 'dict'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-14-df8b555135bb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhurricanes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0mhurricanes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m: '<' not supported between instances of 'dict' and 'dict'" - ] - } - ], - "source": [ - "hurricanes[0] < hurricanes[1]" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'<' not supported between instances of 'dict' and 'dict'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-15-df10618f9841>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhurricanes\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Doesn't work because there isn't a defined \"first\" key in a dict.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m# Unlike tuple, where the first item can be considered \"first\" by ordering.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: '<' not supported between instances of 'dict' and 'dict'" - ] - } - ], - "source": [ - "sorted(hurricanes) # Doesn't work because there isn't a defined \"first\" key in a dict.\n", - "# Unlike tuple, where the first item can be considered \"first\" by ordering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Define get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# a. Input: single hurricane's dict\n", - "# b. Output: return \"year\" value from the dict\n", - "\n", - "def get_year(hurricane):\n", - " print(\"DEBUG: Calling get_year function for:\", hurricane)\n", - " return -hurricane[\"year\"]\n", - "\n", - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Call sorted function using get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# notice we have negative sign in get_year. Double negation == ascending order sort\n", - "sorted(hurricanes, key = get_year, reverse = True) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Define get_speed function" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "def get_speed(hurricane):\n", - " return hurricane.get(\"speed\", 0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Call sorted function using get_speed function for the below hurricanes dict" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'C', 'year': 1990},\n", - " {'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990},\n", - "]\n", - "\n", - "sorted(hurricanes, key = get_speed)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How can you pass string method to sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'C', 'b', 'd']" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'b', 'C', 'd']" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"], key = str.upper)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.8" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_24-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_24-checkpoint.ipynb deleted file mode 100644 index 6a8622f..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/demo_lec_24-checkpoint.ipynb +++ /dev/null @@ -1,756 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1: simple example to demonstrate how to use function references\n", - "## Use PyTutor to go through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def say_hi():\n", - " print(\"Hello there!\")\n", - "\n", - "def say_bye():\n", - " print(\"Wash your hands and stay well, bye!\")\n", - " \n", - "f = say_hi\n", - "f()\n", - "f()\n", - "f = say_bye\n", - "f()\n", - "f()\n", - "f()" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "for i in range(2):\n", - " say_hi()\n", - "\n", - "for i in range(3):\n", - " say_bye()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def call_n_times(f, n):\n", - " for i in range(n):\n", - " f()\n", - "\n", - "call_n_times(say_hi, 2)\n", - "call_n_times(say_bye, 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 2: Apply various transformations to all items on a list" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "L = [\"1\", \"23\", \"456\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Write apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: list object reference, function object\n", - "# b. Output: new list reference to transformed object\n", - "# c. Pseudocode:\n", - "# 1. Initiliaze new empty list for output - we don't want to modify the input list! \n", - "# 2. Process each item in input list\n", - "# 3. Apply the function passed as arugment to 2nd parameter\n", - "# 4. And the transformed item into output list\n", - "# 5. return output list\n", - "\n", - "def apply_to_each(original_L, f):\n", - " new_vals = []\n", - " for val in original_L:\n", - " new_vals.append(f(val))\n", - " return new_vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply int function to list L using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "vals = apply_to_each(L, int)\n", - "vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Write strip_dollar function" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: string value\n", - "# b. Output: transformed string value\n", - "# c. Pseudocode: \n", - "#. 1. Check whether input string begins with $ - what string method do you need here?\n", - "# 2. If so remove it\n", - "\n", - "def strip_dollar(s):\n", - " #Remove the beginning $ sign from string s\n", - " if s.startswith(\"$\"):\n", - " s = s[1:]\n", - " return s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply strip_dollar function and then apply int function" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['1', '23', '456']\n", - "[1, 23, 456]\n" - ] - } - ], - "source": [ - "L = [\"$1\", \"23\", \"$456\"]\n", - "vals = apply_to_each(L, strip_dollar)\n", - "print(vals)\n", - "vals = apply_to_each(vals, int)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Apply upper method call to the below list L by using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['AAA', 'BBB', 'CCC']\n" - ] - } - ], - "source": [ - "L = [\"aaa\", \"bbb\", \"ccc\"]\n", - "vals = apply_to_each(L, str.upper)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## map function" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "L = [\"1\", \"23\", \"456\"]\n", - "list(map(int, L))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3: Custom sort a list of dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990, \"speed\": 250},\n", - "]" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'A', 'year': 2000, 'speed': 150}" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'B', 'year': 1980, 'speed': 100}" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[1]" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'<' not supported between instances of 'dict' and 'dict'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-14-df8b555135bb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhurricanes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0mhurricanes\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m: '<' not supported between instances of 'dict' and 'dict'" - ] - } - ], - "source": [ - "hurricanes[0] < hurricanes[1]" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "'<' not supported between instances of 'dict' and 'dict'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-15-df10618f9841>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msorted\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mhurricanes\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Doesn't work because there isn't a defined \"first\" key in a dict.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m# Unlike tuple, where the first item can be considered \"first\" by ordering.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: '<' not supported between instances of 'dict' and 'dict'" - ] - } - ], - "source": [ - "sorted(hurricanes) # Doesn't work because there isn't a defined \"first\" key in a dict.\n", - "# Unlike tuple, where the first item can be considered \"first\" by ordering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Define get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# a. Input: single hurricane's dict\n", - "# b. Output: return \"year\" value from the dict\n", - "\n", - "def get_year(hurricane):\n", - " print(\"DEBUG: Calling get_year function for:\", hurricane)\n", - " return -hurricane[\"year\"]\n", - "\n", - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Call sorted function using get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# notice we have negative sign in get_year. Double negation == ascending order sort\n", - "sorted(hurricanes, key = get_year, reverse = True) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Define get_speed function" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "def get_speed(hurricane):\n", - " return hurricane.get(\"speed\", 0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Call sorted function using get_speed function for the below hurricanes dict" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'C', 'year': 1990},\n", - " {'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990},\n", - "]\n", - "\n", - "sorted(hurricanes, key = get_speed)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How can you pass string method to sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'C', 'b', 'd']" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'b', 'C', 'd']" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"], key = str.upper)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sorting dictionary by keys using lambda\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* arguments: expression" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bob': 20, 'alice': 8, 'alex': 9}" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players = {\"bob\": 20, \"alice\": 8, \"alex\": 9}\n", - "players" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### This only returns a list of sorted keys. What if we want to create a new sorted dictionary object directly using sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['alex', 'alice', 'bob']" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(players) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's learn about items method on a dictionary\n", - "- returns a list of tuples\n", - "- each tuple item contains two items: key and value" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_items([('bob', 20), ('alice', 8), ('alex', 9)])" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players.items()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alex': 9, 'alice': 8, 'bob': 20}" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(players.items(), key = lambda item: item[0]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What about sorting dictionary by values using lambda?" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alice': 8, 'alex': 9, 'bob': 20}" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(players.items(), key = lambda item: item[1]))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.8" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references-checkpoint.ipynb deleted file mode 100644 index 4e90a15..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references-checkpoint.ipynb +++ /dev/null @@ -1,1006 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Function references" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 1: slide deck example introducing function object references\n", - "#### Use PyTutor to step through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "l1 = [1, 2, 3]\n", - "l2 = l1\n", - "\n", - "def f(l):\n", - " return l[-1]\n", - "\n", - "g = f\n", - "\n", - "num = f(l2)\n", - "print(num)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 2: simple example to demonstrate how to use function references\n", - "#### Use PyTutor to step through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def say_hi():\n", - " print(\"Hello there!\")\n", - "\n", - "def say_bye():\n", - " print(\"Wash your hands and stay well, bye!\")\n", - " \n", - "f = say_hi\n", - "f()\n", - "f()\n", - "f = say_bye\n", - "f()\n", - "f()\n", - "f()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "for i in range(2):\n", - " say_hi()\n", - "\n", - "for i in range(3):\n", - " say_bye()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def call_n_times(f, n):\n", - " for i in range(n):\n", - " f()\n", - "\n", - "call_n_times(say_hi, 2)\n", - "call_n_times(say_bye, 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 3: Apply various transformations to all items on a list" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "L = [\"1\", \"23\", \"456\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Write apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: list object reference, function object\n", - "# b. Output: new list reference to transformed object\n", - "# c. Pseudocode:\n", - "# 1. Initiliaze new empty list for output - we don't want to modify the input list! \n", - "# 2. Process each item in input list\n", - "# 3. Apply the function passed as arugment to 2nd parameter\n", - "# 4. And the transformed item into output list\n", - "# 5. return output list\n", - "\n", - "def apply_to_each(original_L, f):\n", - " new_vals = []\n", - " for val in original_L:\n", - " new_vals.append(f(val))\n", - " return new_vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply int function to list L using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "vals = apply_to_each(L, int)\n", - "vals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Write strip_dollar function" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: string value\n", - "# b. Output: transformed string value\n", - "# c. Pseudocode: \n", - "#. 1. Check whether input string begins with $ - what string method do you need here?\n", - "# 2. If so remove it\n", - "\n", - "def strip_dollar(s):\n", - " #Remove the beginning $ sign from string s\n", - " if s.startswith(\"$\"):\n", - " s = s[1:]\n", - " return s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply strip_dollar function and then apply int function" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['1', '23', '456']\n", - "[1, 23, 456]\n" - ] - } - ], - "source": [ - "L = [\"$1\", \"23\", \"$456\"]\n", - "vals = apply_to_each(L, strip_dollar)\n", - "print(vals)\n", - "vals = apply_to_each(vals, int)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply upper method call to the below list L by using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['AAA', 'BBB', 'CCC']\n" - ] - } - ], - "source": [ - "L = [\"aaa\", \"bbb\", \"ccc\"]\n", - "vals = apply_to_each(L, str.upper)\n", - "print(vals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 4: Custom sort a list of dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990, \"speed\": 250},\n", - "]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Extract hurricane at index 0" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'A', 'year': 2000, 'speed': 150}" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Extract hurricane at index 1" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'B', 'year': 1980, 'speed': 100}" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[1]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Can you compare hurricane at index 0 and hurricane at index 1 using \"<\" operator?" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "# hurricanes[0] < hurricanes[1] #uncomment to see TypeError" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### What about calling sorted method by passing hurricanes as argument?" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "# sorted(hurricanes) # Doesn't work because there isn't a defined \"first\" key in a dict.\n", - "# Unlike tuple, where the first item can be considered \"first\" by ordering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# a. Input: single hurricane's dict\n", - "# b. Output: return \"year\" value from the dict\n", - "\n", - "def get_year(hurricane):\n", - " print(\"DEBUG: Calling get_year function for:\", hurricane)\n", - " return hurricane[\"year\"]\n", - "\n", - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort hurricanes in ascending order of their year" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(hurricanes, key = get_year)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort hurricanes in descending order of their year" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(hurricanes, key = get_year, reverse = True) \n", - "# alternatively get_year function could return negative of year --- that produces the same result\n", - "# as passing True as argument \n", - "# to reverse parameter" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define get_speed function" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "def get_speed(hurricane):\n", - " return hurricane.get(\"speed\", 0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Sort hurricanes in ascending order of their speed" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'C', 'year': 1990},\n", - " {'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990}, # notice the missing speed key\n", - "]\n", - "\n", - "sorted(hurricanes, key = get_speed)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 5: How can you pass string method to sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'C', 'b', 'd']" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'b', 'C', 'd']" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"], key = str.upper)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sorting dictionary by keys using lambda\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* arguments: expression" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 6: sorting dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bob': 20, 'alice': 8, 'alex': 9}" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players = {\"bob\": 20, \"alice\": 8, \"alex\": 9}\n", - "players" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### This only returns a list of sorted keys. What if we want to create a new sorted dictionary object directly using sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['alex', 'alice', 'bob']" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(players) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's learn about items method on a dictionary\n", - "- returns a list of tuples\n", - "- each tuple item contains two items: key and value" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_items([('bob', 20), ('alice', 8), ('alex', 9)])" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players.items()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alex': 9, 'alice': 8, 'bob': 20}" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(players.items(), key = lambda item: item[0]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What about sorting dictionary by values using lambda?" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alice': 8, 'alex': 9, 'bob': 20}" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(players.items(), key = lambda item: item[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Practice: sort a list of tuples" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [], - "source": [ - "badgers_in_nfl = [ (\"Jonathan\", \"Taylor\", 22), # tuple storing (first name, last name, age)\n", - " (\"Russel\", \"Wilson\", 32), \n", - " (\"Melvin\", \"Gordon\", 27), \n", - " (\"JJ\", \"Watt\", 31)\n", - " ]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define functions that will enable extraction of item at each tuple index position\n", - "#### These functions only deal with a single tuple processing" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], - "source": [ - "def select0(some_tuple): # function must have exactly one parameter\n", - " return some_tuple[0]\n", - "\n", - "def select1(some_tuple):\n", - " return some_tuple[1]\n", - "\n", - "def select2(some_tuple):\n", - " return some_tuple[2]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their first name" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('JJ', 'Watt', 31),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select0) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their last name" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Melvin', 'Gordon', 27),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select1) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their age" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select2) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Use lambdas to solve the above three sorting questions" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('JJ', 'Watt', 31),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 33, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Melvin', 'Gordon', 27),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[-1])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.8" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references_template-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references_template-checkpoint.ipynb deleted file mode 100644 index cf90c35..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/function_references_template-checkpoint.ipynb +++ /dev/null @@ -1,974 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Function references" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 1: slide deck example introducing function object references\n", - "#### Use PyTutor to step through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "l1 = [1, 2, 3]\n", - "l2 = l1\n", - "\n", - "def f(l):\n", - " return l[-1]\n", - "\n", - "g = f\n", - "\n", - "num = f(l2)\n", - "print(num)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 2: simple example to demonstrate how to use function references\n", - "#### Use PyTutor to step through this example" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def say_hi():\n", - " print(\"Hello there!\")\n", - "\n", - "def say_bye():\n", - " print(\"Wash your hands and stay well, bye!\")\n", - " \n", - "f = say_hi\n", - "f()\n", - "f()\n", - "f = say_bye\n", - "f()\n", - "f()\n", - "f()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "for i in range(2):\n", - " say_hi()\n", - "\n", - "for i in range(3):\n", - " say_bye()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello there!\n", - "Hello there!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n", - "Wash your hands and stay well, bye!\n" - ] - } - ], - "source": [ - "def call_n_times(f, n):\n", - " for i in range(n):\n", - " f()\n", - "\n", - "call_n_times(say_hi, 2)\n", - "call_n_times(say_bye, 3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 3: Apply various transformations to all items on a list" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "L = [\"1\", \"23\", \"456\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Write apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: list object reference, function object\n", - "# b. Output: new list reference to transformed object\n", - "# c. Pseudocode:\n", - "# 1. Initiliaze new empty list for output - we don't want to modify the input list! \n", - "# 2. Process each item in input list\n", - "# 3. Apply the function passed as arugment to 2nd parameter\n", - "# 4. And the transformed item into output list\n", - "# 5. return output list\n", - "\n", - "def apply_to_each(original_L, f):\n", - " pass\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply int function to list L using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 23, 456]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Write strip_dollar function" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "# a. Input: string value\n", - "# b. Output: transformed string value\n", - "# c. Pseudocode: \n", - "#. 1. Check whether input string begins with $ - what string method do you need here?\n", - "# 2. If so remove it\n", - "\n", - "def strip_dollar(s):\n", - " pass" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply strip_dollar function and then apply int function" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['1', '23', '456']\n", - "[1, 23, 456]\n" - ] - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Apply upper method call to the below list L by using apply_to_each function" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['AAA', 'BBB', 'CCC']\n" - ] - } - ], - "source": [ - "L = [\"aaa\", \"bbb\", \"ccc\"]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 4: Custom sort a list of dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990, \"speed\": 250},\n", - "]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Extract hurricane at index 0" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'A', 'year': 2000, 'speed': 150}" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Extract hurricane at index 1" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'name': 'B', 'year': 1980, 'speed': 100}" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes[1]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Can you compare hurricane at index 0 and hurricane at index 1 using \"<\" operator?" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "# hurricanes[0] < hurricanes[1] #uncomment to see TypeError" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### What about calling sorted method by passing hurricanes as argument?" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "# sorted(hurricanes) # Doesn't work because there isn't a defined \"first\" key in a dict.\n", - "# Unlike tuple, where the first item can be considered \"first\" by ordering." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define get_year function" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# a. Input: single hurricane's dict\n", - "# b. Output: return \"year\" value from the dict\n", - "\n", - "def get_year(hurricane):\n", - " pass\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort hurricanes in ascending order of their year" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort hurricanes in descending order of their year" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DEBUG: Calling get_year function for: {'name': 'A', 'year': 2000, 'speed': 150}\n", - "DEBUG: Calling get_year function for: {'name': 'B', 'year': 1980, 'speed': 100}\n", - "DEBUG: Calling get_year function for: {'name': 'C', 'year': 1990, 'speed': 250}\n" - ] - }, - { - "data": { - "text/plain": [ - "[{'name': 'A', 'year': 2000, 'speed': 150},\n", - " {'name': 'C', 'year': 1990, 'speed': 250},\n", - " {'name': 'B', 'year': 1980, 'speed': 100}]" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define get_speed function" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "def get_speed(hurricane):\n", - " pass" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Sort hurricanes in ascending order of their speed" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'C', 'year': 1990},\n", - " {'name': 'B', 'year': 1980, 'speed': 100},\n", - " {'name': 'A', 'year': 2000, 'speed': 150}]" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "hurricanes = [\n", - " {\"name\": \"A\", \"year\": 2000, \"speed\": 150},\n", - " {\"name\": \"B\", \"year\": 1980, \"speed\": 100},\n", - " {\"name\": \"C\", \"year\": 1990}, # notice the missing speed key\n", - "]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 5: How can you pass string method to sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'C', 'b', 'd']" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['A', 'b', 'C', 'd']" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted([\"A\", \"b\", \"C\", \"d\"], key = str.upper)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sorting dictionary by keys using lambda\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* arguments: expression" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 6: sorting dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bob': 20, 'alice': 8, 'alex': 9}" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players = {\"bob\": 20, \"alice\": 8, \"alex\": 9}\n", - "players" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### This only returns a list of sorted keys. What if we want to create a new sorted dictionary object directly using sorted function?" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['alex', 'alice', 'bob']" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(players) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's learn about items method on a dictionary\n", - "- returns a list of tuples\n", - "- each tuple item contains two items: key and value" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_items([('bob', 20), ('alice', 8), ('alex', 9)])" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "players.items()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alex': 9, 'alice': 8, 'bob': 20}" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What about sorting dictionary by values using lambda?" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'alice': 8, 'alex': 9, 'bob': 20}" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Practice: sort a list of tuples" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [], - "source": [ - "badgers_in_nfl = [ (\"Jonathan\", \"Taylor\", 22), # tuple storing (first name, last name, age)\n", - " (\"Russel\", \"Wilson\", 32), \n", - " (\"Melvin\", \"Gordon\", 27), \n", - " (\"JJ\", \"Watt\", 31)\n", - " ]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Define functions that will enable extraction of item at each tuple index position\n", - "#### These functions only deal with a single tuple processing" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], - "source": [ - "def select0(some_tuple): # function must have exactly one parameter\n", - " return some_tuple[0]\n", - "\n", - "def select1(some_tuple):\n", - " return some_tuple[1]\n", - "\n", - "def select2(some_tuple):\n", - " return some_tuple[2]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their first name" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('JJ', 'Watt', 31),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select0) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their last name" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Melvin', 'Gordon', 27),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select1) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort players by their age" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = select2) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Use lambdas to solve the above three sorting questions" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('JJ', 'Watt', 31),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 33, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Melvin', 'Gordon', 27),\n", - " ('Jonathan', 'Taylor', 22),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('Jonathan', 'Taylor', 22),\n", - " ('Melvin', 'Gordon', 27),\n", - " ('JJ', 'Watt', 31),\n", - " ('Russel', 'Wilson', 32)]" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(badgers_in_nfl, key = lambda t : t[-1])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.8.8" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-Copy1-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-Copy1-checkpoint.ipynb deleted file mode 100644 index cad6868..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-Copy1-checkpoint.ipynb +++ /dev/null @@ -1,1035 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Comprehensions" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import statements\n", - "import math\n", - "import csv" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Review of lambdas\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* parameters: expression" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's sort the menu in different ways\n", - "- whenever you need to custom sort a dictionary, you must convert dict to list of tuples\n", - "- recall that you can use items method (applicable only to a dictionary)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu = { \n", - " 'broccoli': 4.99,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95, \n", - " 'donut': 1.25, \n", - " 'muffin': 2.25,\n", - " 'cookie': 0.79, \n", - " 'milk':1.65, \n", - " 'bread': 5.99} \n", - "menu" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu.items()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using item names (keys)\n", - "- let's first solve this using extract function\n", - "- recall that extract function deals with one of the inner items in the outer data structure\n", - " - outer data structure is list\n", - " - inner data structure is tuple" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def extract(???):\n", - " return ???" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sorted(menu.items(), key = ???)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using lambdas\n", - "- if you are having trouble thinking through the lambda solution directly:\n", - " - write an extract function\n", - " - then abstract it to a lambda" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using prices (values)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using length of item names (keys)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???, ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Iterable\n", - "\n", - "- What is an iterable? Anything that you can write a for loop to iterate over is called as an iterable.\n", - "- Examples of iteratables:\n", - " - `list`, `str`, `tuple`, `range()` (any sequence)\n", - " - `dict`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## List comprehensions\n", - "\n", - "- concise way of generating a new list based on existing list item manipulation \n", - "- short syntax - easier to read, very difficult to debug\n", - "\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "- iteratble: reference to any iterable object instance\n", - "- conditional_expression: filters the values in the original list based on a specific requirement\n", - "- expression: can simply be val or some other transformation of val\n", - "- enclosing [ ] represents new list\n", - "\n", - "Best approach:\n", - "- write for clause first\n", - "- if condition expression next\n", - "- expression in front of for clause last" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Which animals are in all caps?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Recap: retain animals in all caps\n", - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "caps_animals = []\n", - "print(\"Original:\", animals)\n", - "\n", - "\n", - " \n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using list comprehension\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "For the below example:\n", - "- iterable: animals variable (storing reference to a list object instance)\n", - "- conditional_expression: val.upper() == val\n", - "- expression: val itself" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# List comprehension version\n", - "print(\"Original:\", animals)\n", - "\n", - "caps_animals = ???\n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Why is to tougher to debug?\n", - "- you cannot use a print function call in a comprehension\n", - "- you need to decompose each part and test it separately\n", - "- recommended to write the comprehension with a simpler example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Other than a badger, what animals can you see at Henry Vilas Zoo?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = ???\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we convert all of the animals to all caps?\n", - "- if clause is optional" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "all_caps_animals = ???\n", - "print(\"New list:\", all_caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we generate a list to store length of each animal name?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "animals_name_length = ???\n", - "print(\"New list:\", animals_name_length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Using if ... else ... in a list comprehension\n", - "- syntax changes slightly for if ... else ...\n", - "\n", - "<pre>\n", - "new_list = [expression if conditional_expression else alternate_expression for val in iterable ]\n", - "</pre>\n", - "\n", - "- when an item satifies the if clause, you don't execute the else clause\n", - " - expression is the item in new list when if condition is satified\n", - "- when an item does not satisfy the if clause, you execute the else clause\n", - " - alternate_expression is the item in new list when if condition is not satisfied\n", - " \n", - "- if ... else ... clauses need to come before for (not the same as just using if clause)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What if we only care about the badger? Replace non-badger animals with \"some animal\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = ???\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Dict comprehensions\n", - "- Version 1:\n", - "<pre>\n", - "{expression for val in iterable if condition}\n", - "</pre>\n", - "- expression has the form <pre>key: val</pre>\n", - "<br/>\n", - "- Version 2 --- the dict function call by passing list comprehension as argument:\n", - "<pre>dict([expression for val in iterable if condition])</pre>\n", - "- expression has the form <pre>(key, val)</pre>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dict to map number to its square (for numbers 1 to 5)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "squares_dict = dict()\n", - "for val in range(1, 6):\n", - " squares_dict[val] = val * val\n", - "print(squares_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "square_dict = ???\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "square_dict = ???\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Tuple unpacking\n", - "- you can directly specific variables to unpack the items inside a tuple" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "\n", - "for tuple_item in scores_dict.items():\n", - " print(tuple_item)\n", - " \n", - "print(\"--------------------\")\n", - "\n", - "for ??? in scores_dict.items():\n", - " print(key, val)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### From square_dict, let's generate cube_dict" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "cube_dict = {key: ??? for key, val in square_dict.items()}\n", - "print(cube_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert Madison *F temperature to *C\n", - "- <pre>C = 5 / 9 * (F - 32)</pre>" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "madison_fahrenheit = {'Nov': 28,'Dec': 20, 'Jan': 10,'Feb': 14}\n", - "print(\"Original:\", madison_fahrenheit)\n", - "\n", - "madison_celsius = {key: ??? \\\n", - " for key, val in madison_fahrenheit.items()}\n", - "print(\"New dict:\", madison_celsius)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert type of values in a dictionary" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "print(\"Original:\", scores_dict)\n", - "\n", - "updated_scores_dict = {???}\n", - "print(\"New dict:\", updated_scores_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dictionary to map each player to their max score" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n", - "{player: max(scores) for player, scores in scores_dict.items()}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - sorted + lambda" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Use sorted and lambda function to sort this list of dictionaries based on the score, from low to high" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores = [ {\"name\": \"Bob\", \"score\": 32} ,\n", - " {\"name\": \"Cindy\", \"score\" : 45}, \n", - " {\"name\": \"Alice\", \"score\": 39}\n", - " ]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, modify the lambda function part alone to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, go back to the previous lambda function definition and use sorted parameters to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Student Information Survey dataset analysis" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def median(items):\n", - " items.sort()\n", - " n = len(items)\n", - " if n % 2 != 0:\n", - " middle = items[n // 2]\n", - " else:\n", - " first_middle = items[n // 2]\n", - " second_middle = items[(n // 2) - 1]\n", - " middle = (first_middle + second_middle) / 2\n", - " return middle" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# inspired by https://automatetheboringstuff.com/2e/chapter16/\n", - "def process_csv(filename):\n", - " exampleFile = open(filename, encoding=\"utf-8\") \n", - " exampleReader = csv.reader(exampleFile) \n", - " exampleData = list(exampleReader) \n", - " exampleFile.close() \n", - " return exampleData\n", - "\n", - "survey_data = process_csv('cs220_survey_data.csv')\n", - "cs220_header = survey_data[0]\n", - "cs220_data = survey_data[1:]\n", - "cs220_header" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def cell(row_idx, col_name):\n", - " \"\"\"\n", - " Returns the data value (cell) corresponding to the row index and \n", - " the column name of a CSV file.\n", - " \"\"\"\n", - " col_idx = cs220_header.index(col_name) \n", - " val = cs220_data[row_idx][col_idx] \n", - " \n", - " # handle missing values, by returning None\n", - " if val == '':\n", - " return None\n", - " \n", - " # handle type conversions\n", - " if col_name in [\"Age\",]:\n", - " return int(val)\n", - " \n", - " return val" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def transform(header, data):\n", - " \"\"\"\n", - " Transform data into a list of dictionaries, while taking care of type conversions\n", - " \"\"\"\n", - " #should be defined outside the for loop, because it stores the entire data\n", - " dict_list = [] \n", - " for row in data:\n", - " #should be defined inside the for loop, because it represents one row as a \n", - " #dictionary\n", - " new_row = {} \n", - " for i in range(len(header)):\n", - " if header[i] == \"Age\":\n", - " if row[i] == '':\n", - " new_row[header[i]] = None\n", - " else:\n", - " new_row[header[i]] = int(row[i])\n", - " else:\n", - " new_row[header[i]] = row[i]\n", - " dict_list.append(new_row)\n", - " return dict_list\n", - " \n", - "transformed_data = transform(cs220_header, cs220_data)\n", - "transformed_data[:2] # top 2 rows" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def bucketize(data, bucket_column):\n", - " \"\"\"\n", - " data: expects list of dictionaries\n", - " bucket_column: column for bucketization\n", - " generates and returns bucketized data based on bucket_column\n", - " \"\"\"\n", - " # Key: unique bucketize column value; Value: list of dictionaries \n", - " # (rows having that unique column value)\n", - " buckets = dict()\n", - " for row_dict in data:\n", - " col_value = row_dict[bucket_column]\n", - " if col_value not in buckets:\n", - " buckets[col_value] = []\n", - " buckets[col_value].append(row_dict)\n", - " \n", - " return buckets" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is the average age of \"LEC001\" students?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "lecture_buckets = bucketize(transformed_data, \"Lecture\")\n", - "lec001_bucket = lecture_buckets[\"LEC001\"]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is the average age of \"LEC001\" students who like \"pineapple\" pizza topping?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What are the sleep habits of the youngest students?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "min_age = None\n", - "\n", - "# pass 1: find minimum age\n", - "\n", - "\n", - "# pass 2: find sleep habit of students with minimum age\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How many students are there is each lecture?\n", - "- Create a `dict` mapping each lecture to the count of students." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# v1\n", - "{}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# v2\n", - "{}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Find whether 15 oldest students in the class are runners?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "students_with_age = []" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Compute median age per lecture in one step using `dict` and `list` comprehension." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "age_by_lecture = {} # Key: lecture; Value: list of ages\n", - "\n", - "for lecture in lecture_buckets:\n", - " lecture_students = lecture_buckets[lecture]\n", - " ages = []\n", - " for student in lecture_students:\n", - " age = student[\"Age\"]\n", - " if age == None:\n", - " continue\n", - " ages.append(age)\n", - " age_by_lecture[lecture] = ages\n", - "\n", - "median_age_by_lecture = {} # Key: lecture; Value: median age of that lecture\n", - "for lecture in age_by_lecture:\n", - " median_age = median(age_by_lecture[lecture])\n", - " median_age_by_lecture[lecture] = median_age\n", - " \n", - "print(median_age_by_lecture)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Compute max age per lecture in one step using `dict` and `list` comprehension." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - comprehensions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list where each number is a square of the original nummber in numbers list" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numbers = [44, 33, 56, 21, 19]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of floats from vac_rates, that is rounded to 3 decimal points" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vac_rates = [23.329868, 51.28772, 76.12232, 17.2, 10.5]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of ints from words, that contains length of each word" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "words = ['My', 'very', 'educated', 'mother', 'just', 'served', 'us', 'noodles']\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create 2 dictionaries to map each player to their min and avg score" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Student Information Survey dataset" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create dict mapping unique age to count of students with that age.\n", - "- Order the dictionary based on increasing order of ages\n", - "- Make sure to drop student dictionaries which don't have Age column information (we already did this in a previous example)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Find whether 15 youngest students in the class are pet owners?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-checkpoint.ipynb deleted file mode 100644 index b6390a5..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions-checkpoint.ipynb +++ /dev/null @@ -1,1678 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Comprehensions" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# import statements\n", - "import math\n", - "import csv" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Review of lambdas\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* parameters: expression" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's sort the menu in different ways\n", - "- whenever you need to custom sort a dictionary, you must convert dict to list of tuples\n", - "- recall that you can use items method (applicable only to a dictionary)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'broccoli': 4.99,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95,\n", - " 'donut': 1.25,\n", - " 'muffin': 2.25,\n", - " 'cookie': 0.79,\n", - " 'milk': 1.65,\n", - " 'bread': 5.99}" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "menu = { \n", - " 'broccoli': 4.99,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95, \n", - " 'donut': 1.25, \n", - " 'muffin': 2.25,\n", - " 'cookie': 0.79, \n", - " 'milk':1.65, \n", - " 'bread': 5.99} \n", - "menu" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "dict_items([('broccoli', 4.99), ('orange', 1.19), ('pie', 3.95), ('donut', 1.25), ('muffin', 2.25), ('cookie', 0.79), ('milk', 1.65), ('bread', 5.99)])" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "menu.items()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using item names (keys)\n", - "- let's first solve this using extract function\n", - "- recall that extract function deals with one of the inner items in the outer data structure\n", - " - outer data structure is list\n", - " - inner data structure is tuple" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def extract(menu_tuple):\n", - " return menu_tuple[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[('bread', 5.99),\n", - " ('broccoli', 4.99),\n", - " ('cookie', 0.79),\n", - " ('donut', 1.25),\n", - " ('milk', 1.65),\n", - " ('muffin', 2.25),\n", - " ('orange', 1.19),\n", - " ('pie', 3.95)]" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(menu.items(), key = extract)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bread': 5.99,\n", - " 'broccoli': 4.99,\n", - " 'cookie': 0.79,\n", - " 'donut': 1.25,\n", - " 'milk': 1.65,\n", - " 'muffin': 2.25,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = extract))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using lambdas\n", - "- if you are having trouble thinking through the lambda solution directly:\n", - " - write an extract function\n", - " - then abstract it to a lambda" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bread': 5.99,\n", - " 'broccoli': 4.99,\n", - " 'cookie': 0.79,\n", - " 'donut': 1.25,\n", - " 'milk': 1.65,\n", - " 'muffin': 2.25,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95}" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: menu_tuple[0]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using prices (values)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'cookie': 0.79,\n", - " 'orange': 1.19,\n", - " 'donut': 1.25,\n", - " 'milk': 1.65,\n", - " 'muffin': 2.25,\n", - " 'pie': 3.95,\n", - " 'broccoli': 4.99,\n", - " 'bread': 5.99}" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: menu_tuple[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using length of item names (keys)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'pie': 3.95,\n", - " 'milk': 1.65,\n", - " 'donut': 1.25,\n", - " 'bread': 5.99,\n", - " 'orange': 1.19,\n", - " 'muffin': 2.25,\n", - " 'cookie': 0.79,\n", - " 'broccoli': 4.99}" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: len(menu_tuple[0])))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v1" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bread': 5.99,\n", - " 'broccoli': 4.99,\n", - " 'pie': 3.95,\n", - " 'muffin': 2.25,\n", - " 'milk': 1.65,\n", - " 'donut': 1.25,\n", - " 'orange': 1.19,\n", - " 'cookie': 0.79}" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: menu_tuple[1], reverse = True))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v2" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'bread': 5.99,\n", - " 'broccoli': 4.99,\n", - " 'pie': 3.95,\n", - " 'muffin': 2.25,\n", - " 'milk': 1.65,\n", - " 'donut': 1.25,\n", - " 'orange': 1.19,\n", - " 'cookie': 0.79}" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: -menu_tuple[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Iterable\n", - "\n", - "- What is an iterable? Anything that you can write a for loop to iterate over is called as an iterable.\n", - "- Examples of iteratables:\n", - " - `list`, `str`, `tuple`, `range()` (any sequence)\n", - " - `dict`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## List comprehensions\n", - "\n", - "- concise way of generating a new list based on existing list item manipulation \n", - "- short syntax - easier to read, very difficult to debug\n", - "\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "- iteratble: reference to any iterable object instance\n", - "- conditional_expression: filters the values in the original list based on a specific requirement\n", - "- expression: can simply be val or some other transformation of val\n", - "- enclosing [ ] represents new list\n", - "\n", - "Best approach:\n", - "- write for clause first\n", - "- if condition expression next\n", - "- expression in front of for clause last" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Which animals are in all caps?" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: ['RHINO', 'GIRAFFE']\n" - ] - } - ], - "source": [ - "# Recap: retain animals in all caps\n", - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "caps_animals = []\n", - "print(\"Original:\", animals)\n", - "\n", - "for val in animals:\n", - " if val.upper() == val: # Do we want to keep the current animal?\n", - " caps_animals.append(val)\n", - " \n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using list comprehension\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "For the below example:\n", - "- iterable: animals variable (storing reference to a list object instance)\n", - "- conditional_expression: val.upper() == val\n", - "- expression: val itself" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: ['RHINO', 'GIRAFFE']\n" - ] - } - ], - "source": [ - "# List comprehension version\n", - "print(\"Original:\", animals)\n", - "\n", - "caps_animals = [val for val in animals if val.upper() == val]\n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Why is to tougher to debug?\n", - "- you cannot use a print function call in a comprehension\n", - "- you need to decompose each part and test it separately\n", - "- recommended to write the comprehension with a simpler example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Other than a badger, what animals can you see at Henry Vilas Zoo?" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: ['lion', 'RHINO', 'GIRAFFE']\n" - ] - } - ], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = [val for val in animals if val.upper() != \"BADGER\"]\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we convert all of the animals to all caps?\n", - "- if clause is optional" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: ['LION', 'BADGER', 'RHINO', 'GIRAFFE']\n" - ] - } - ], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "all_caps_animals = [val.upper() for val in animals]\n", - "print(\"New list:\", all_caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we generate a list to store length of each animal name?" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: [4, 6, 5, 7]\n" - ] - } - ], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "animals_name_length = [len(val) for val in animals]\n", - "print(\"New list:\", animals_name_length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Using if ... else ... in a list comprehension\n", - "- syntax changes slightly for if ... else ...\n", - "\n", - "<pre>\n", - "new_list = [expression if conditional_expression else alternate_expression for val in iterable ]\n", - "</pre>\n", - "\n", - "- when an item satifies the if clause, you don't execute the else clause\n", - " - expression is the item in new list when if condition is satified\n", - "- when an item does not satisfy the if clause, you execute the else clause\n", - " - alternate_expression is the item in new list when if condition is not satisfied\n", - " \n", - "- if ... else ... clauses need to come before for (not the same as just using if clause)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What if we only care about the badger? Replace non-badger animals with \"some animal\"." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: ['lion', 'badger', 'RHINO', 'GIRAFFE']\n", - "New list: ['some animal', 'badger', 'some animal', 'some animal']\n" - ] - } - ], - "source": [ - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = [val if val.upper() == \"BADGER\" else \"some animal\" \\\n", - " for val in animals]\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Dict comprehensions\n", - "- Version 1:\n", - "<pre>\n", - "{expression for val in iterable if condition}\n", - "</pre>\n", - "- expression has the form <pre>key: val</pre>\n", - "<br/>\n", - "- Version 2 --- the dict function call by passing list comprehension as argument:\n", - "<pre>dict([expression for val in iterable if condition])</pre>\n", - "- expression has the form <pre>(key, val)</pre>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dict to map number to its square (for numbers 1 to 5)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}\n" - ] - } - ], - "source": [ - "squares_dict = dict()\n", - "for val in range(1, 6):\n", - " squares_dict[val] = val * val\n", - "print(squares_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 1" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}\n" - ] - } - ], - "source": [ - "square_dict = {val: val * val for val in range(1, 6)}\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 2" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}\n" - ] - } - ], - "source": [ - "square_dict = dict([(val, val * val) for val in range(1, 6)])\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Tuple unpacking\n", - "- you can directly specific variables to unpack the items inside a tuple" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('Bob', '32')\n", - "('Cindy', '45')\n", - "('Alice', '39')\n", - "('Unknown', 'None')\n", - "--------------------\n", - "Bob 32\n", - "Cindy 45\n", - "Alice 39\n", - "Unknown None\n" - ] - } - ], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "\n", - "for tuple_item in scores_dict.items():\n", - " print(tuple_item)\n", - " \n", - "print(\"--------------------\")\n", - "\n", - "for key, val in scores_dict.items():\n", - " print(key, val)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### From square_dict, let's generate cube_dict" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1: 1, 2: 8, 3: 27, 4: 64, 5: 125}\n" - ] - } - ], - "source": [ - "cube_dict = {key: int(math.sqrt(val)) ** 3 for key, val in square_dict.items()}\n", - "print(cube_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert Madison *F temperature to *C\n", - "- <pre>C = 5 / 9 * (F - 32)</pre>" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: {'Nov': 28, 'Dec': 20, 'Jan': 10, 'Feb': 14}\n", - "New dict: {'Nov': -2, 'Dec': -6, 'Jan': -12, 'Feb': -10}\n" - ] - } - ], - "source": [ - "madison_fahrenheit = {'Nov': 28,'Dec': 20, 'Jan': 10,'Feb': 14}\n", - "print(\"Original:\", madison_fahrenheit)\n", - "\n", - "madison_celsius = {key: int(5 / 9 * (val - 32)) \\\n", - " for key, val in madison_fahrenheit.items()}\n", - "print(\"New dict:\", madison_celsius)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert type of values in a dictionary" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original: {'Bob': '32', 'Cindy': '45', 'Alice': '39', 'Unknown': 'None'}\n", - "New dict: {'Bob': 32, 'Cindy': 45, 'Alice': 39, 'Unknown': None}\n" - ] - } - ], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "print(\"Original:\", scores_dict)\n", - "\n", - "updated_scores_dict = {key: int(val) if val.isdigit() else None \\\n", - " for key, val in scores_dict.items()}\n", - "print(\"New dict:\", updated_scores_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dictionary to map each player to their max score" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Bob': 83, 'Cindy': 87, 'Alice': 90, 'Meena': 93}" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n", - "{player: max(scores) for player, scores in scores_dict.items()}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - sorted + lambda" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Use sorted and lambda function to sort this list of dictionaries based on the score, from low to high" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'Bob', 'score': 32},\n", - " {'name': 'Alice', 'score': 39},\n", - " {'name': 'Cindy', 'score': 45}]" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "scores = [ {\"name\": \"Bob\", \"score\": 32} ,\n", - " {\"name\": \"Cindy\", \"score\" : 45}, \n", - " {\"name\": \"Alice\", \"score\": 39}\n", - " ]\n", - "\n", - "sorted(scores, key = lambda d: d[\"score\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, modify the lambda function part alone to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'Cindy', 'score': 45},\n", - " {'name': 'Alice', 'score': 39},\n", - " {'name': 'Bob', 'score': 32}]" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(scores, key = lambda d: -d[\"score\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, go back to the previous lambda function definition and use sorted parameters to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'name': 'Cindy', 'score': 45},\n", - " {'name': 'Alice', 'score': 39},\n", - " {'name': 'Bob', 'score': 32}]" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sorted(scores, key = lambda d: d[\"score\"], reverse = True)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Student Information Survey dataset analysis" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [], - "source": [ - "def median(items):\n", - " items.sort()\n", - " n = len(items)\n", - " if n % 2 != 0:\n", - " middle = items[n // 2]\n", - " else:\n", - " first_middle = items[n // 2]\n", - " second_middle = items[(n // 2) - 1]\n", - " middle = (first_middle + second_middle) / 2\n", - " return middle" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['Lecture',\n", - " 'Age',\n", - " 'Primary major',\n", - " 'Other majors',\n", - " 'Zip Code',\n", - " 'Pizza topping',\n", - " 'Pet owner',\n", - " 'Runner',\n", - " 'Sleep habit',\n", - " 'Procrastinator']" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# inspired by https://automatetheboringstuff.com/2e/chapter16/\n", - "def process_csv(filename):\n", - " exampleFile = open(filename, encoding=\"utf-8\") \n", - " exampleReader = csv.reader(exampleFile) \n", - " exampleData = list(exampleReader) \n", - " exampleFile.close() \n", - " return exampleData\n", - "\n", - "survey_data = process_csv('cs220_survey_data.csv')\n", - "cs220_header = survey_data[0]\n", - "cs220_data = survey_data[1:]\n", - "cs220_header" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [], - "source": [ - "def cell(row_idx, col_name):\n", - " \"\"\"\n", - " Returns the data value (cell) corresponding to the row index and \n", - " the column name of a CSV file.\n", - " \"\"\"\n", - " col_idx = cs220_header.index(col_name) \n", - " val = cs220_data[row_idx][col_idx] \n", - " \n", - " # handle missing values, by returning None\n", - " if val == '':\n", - " return None\n", - " \n", - " # handle type conversions\n", - " if col_name in [\"Age\",]:\n", - " return int(val)\n", - " \n", - " return val" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[{'Lecture': 'LEC002',\n", - " 'Age': 19,\n", - " 'Primary major': 'Engineering: Mechanical',\n", - " 'Other majors': '',\n", - " 'Zip Code': '53711',\n", - " 'Pizza topping': 'pepperoni',\n", - " 'Pet owner': 'Yes',\n", - " 'Runner': 'No',\n", - " 'Sleep habit': 'night owl',\n", - " 'Procrastinator': 'Maybe'},\n", - " {'Lecture': 'LEC002',\n", - " 'Age': 20,\n", - " 'Primary major': 'Science: Physics',\n", - " 'Other majors': 'Astronomy-Physics, History',\n", - " 'Zip Code': '53726',\n", - " 'Pizza topping': 'pineapple',\n", - " 'Pet owner': 'Yes',\n", - " 'Runner': 'Yes',\n", - " 'Sleep habit': 'night owl',\n", - " 'Procrastinator': 'Yes'}]" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def transform(header, data):\n", - " \"\"\"\n", - " Transform data into a list of dictionaries, while taking care of type conversions\n", - " \"\"\"\n", - " #should be defined outside the for loop, because it stores the entire data\n", - " dict_list = [] \n", - " for row in data:\n", - " #should be defined inside the for loop, because it represents one row as a \n", - " #dictionary\n", - " new_row = {} \n", - " for i in range(len(header)):\n", - " if header[i] == \"Age\":\n", - " if row[i] == '':\n", - " new_row[header[i]] = None\n", - " else:\n", - " new_row[header[i]] = int(row[i])\n", - " else:\n", - " new_row[header[i]] = row[i]\n", - " dict_list.append(new_row)\n", - " return dict_list\n", - " \n", - "transformed_data = transform(cs220_header, cs220_data)\n", - "transformed_data[:2] # top 2 rows" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [], - "source": [ - "def bucketize(data, bucket_column):\n", - " \"\"\"\n", - " data: expects list of dictionaries\n", - " bucket_column: column for bucketization\n", - " generates and returns bucketized data based on bucket_column\n", - " \"\"\"\n", - " # Key: unique bucketize column value; Value: list of dictionaries \n", - " # (rows having that unique column value)\n", - " buckets = dict()\n", - " for row_dict in data:\n", - " col_value = row_dict[bucket_column]\n", - " if col_value not in buckets:\n", - " buckets[col_value] = []\n", - " buckets[col_value].append(row_dict)\n", - " \n", - " return buckets" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is the average age of \"LEC001\" students?" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "19.93" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "lecture_buckets = bucketize(transformed_data, \"Lecture\")\n", - "lec001_bucket = lecture_buckets[\"LEC001\"]\n", - "lec001_ages = [student_dict[\"Age\"] for student_dict in lec001_bucket \\\n", - " if student_dict[\"Age\"] != None]\n", - "round(sum(lec001_ages) / len(lec001_ages), 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is the average age of \"LEC001\" students who like \"pineapple\" pizza topping?" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "20.39" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "lec001_pineapple_ages = [student_dict[\"Age\"] for student_dict in lec001_bucket \\\n", - " if student_dict[\"Age\"] != None and \\\n", - " student_dict[\"Pizza topping\"] == \"pineapple\"]\n", - "round(sum(lec001_pineapple_ages) / len(lec001_pineapple_ages), 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What are the sleep habits of the youngest students?" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['no preference', 'night owl']" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "min_age = None\n", - "\n", - "# pass 1: find minimum age\n", - "for student_dict in transformed_data:\n", - " age = student_dict[\"Age\"]\n", - " if age == None:\n", - " continue\n", - " if min_age == None or age < min_age:\n", - " min_age = age\n", - "\n", - "# pass 2: find sleep habit of students with minimum age\n", - "sleep_habits = [student_dict[\"Sleep habit\"] for student_dict in transformed_data\\\n", - " if student_dict[\"Age\"] != None and student_dict[\"Age\"] == min_age]\n", - "sleep_habits" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How many students are there is each lecture?\n", - "- Create a `dict` mapping each lecture to the count of students." - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'LEC002': 161, 'LEC001': 239, 'LEC004': 129, 'LEC003': 191}" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# v1\n", - "{lecture:len(lecture_buckets[lecture]) for lecture in lecture_buckets}" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'LEC002': 161, 'LEC001': 239, 'LEC004': 129, 'LEC003': 191}" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# v2\n", - "{lecture:len(students) for lecture, students in lecture_buckets.items()}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Find whether 15 oldest students in the class are runners?" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'No']" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "students_with_age = [student_dict for student_dict in transformed_data \\\n", - " if student_dict[\"Age\"] != None]\n", - "[student_dict[\"Runner\"] for student_dict in sorted(students_with_age, \\\n", - " key = lambda s_dict: s_dict[\"Age\"], reverse = True)[:15]]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Compute median age per lecture in one step using `dict` and `list` comprehension." - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'LEC002': 19.0, 'LEC001': 19, 'LEC004': 19.0, 'LEC003': 19}\n" - ] - } - ], - "source": [ - "age_by_lecture = {} # Key: lecture; Value: list of ages\n", - "\n", - "for lecture in lecture_buckets:\n", - " lecture_students = lecture_buckets[lecture]\n", - " ages = []\n", - " for student in lecture_students:\n", - " age = student[\"Age\"]\n", - " if age == None:\n", - " continue\n", - " ages.append(age)\n", - " age_by_lecture[lecture] = ages\n", - "\n", - "median_age_by_lecture = {} # Key: lecture; Value: median age of that lecture\n", - "for lecture in age_by_lecture:\n", - " median_age = median(age_by_lecture[lecture])\n", - " median_age_by_lecture[lecture] = median_age\n", - " \n", - "print(median_age_by_lecture)" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'LEC002': 19.0, 'LEC001': 19, 'LEC004': 19.0, 'LEC003': 19}" - ] - }, - "execution_count": 41, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "median_age_by_lecture2 = {lecture: median([student[\"Age\"] for student in students \\\n", - " if student[\"Age\"] != None]) \\\n", - " for lecture, students in lecture_buckets.items()}\n", - "median_age_by_lecture2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Compute max age per lecture in one step using `dict` and `list` comprehension." - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'LEC002': 28, 'LEC001': 36, 'LEC004': 23, 'LEC003': 27}" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "max_age_by_lecture2 = {lecture: max([student[\"Age\"] for student in students \\\n", - " if student[\"Age\"] != None]) \\\n", - " for lecture, students in lecture_buckets.items()}\n", - "max_age_by_lecture2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - comprehensions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list where each number is a square of the original nummber in numbers list" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1936, 1089, 3136, 441, 361]" - ] - }, - "execution_count": 43, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "numbers = [44, 33, 56, 21, 19]\n", - "\n", - "[num ** 2 for num in numbers]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of floats from vac_rates, that is rounded to 3 decimal points" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[23.33, 51.288, 76.122, 17.2, 10.5]" - ] - }, - "execution_count": 44, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "vac_rates = [23.329868, 51.28772, 76.12232, 17.2, 10.5]\n", - "\n", - "[round(rate, 3) for rate in vac_rates]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of ints from words, that contains length of each word" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[2, 4, 8, 6, 4, 6, 2, 7]" - ] - }, - "execution_count": 45, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "words = ['My', 'very', 'educated', 'mother', 'just', 'served', 'us', 'noodles']\n", - "\n", - "[len(word) for word in words]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create 2 dictionaries to map each player to their min and avg score" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Bob': 5, 'Cindy': 11, 'Alice': 16, 'Meena': 3}" - ] - }, - "execution_count": 46, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n", - "{player: min(scores) for player, scores in scores_dict.items()}" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Bob': 47.8, 'Cindy': 50.6, 'Alice': 54.0, 'Meena': 39.8}" - ] - }, - "execution_count": 47, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "{player: sum(scores) / len(scores) for player, scores in scores_dict.items()}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Student Information Survey dataset" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create dict mapping unique age to count of students with that age.\n", - "- Order the dictionary based on increasing order of ages\n", - "- Make sure to drop student dictionaries which don't have Age column information (we already did this in a previous example)" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{17: 2,\n", - " 18: 180,\n", - " 19: 226,\n", - " 20: 144,\n", - " 21: 89,\n", - " 22: 25,\n", - " 23: 15,\n", - " 24: 10,\n", - " 25: 4,\n", - " 26: 2,\n", - " 27: 5,\n", - " 28: 1,\n", - " 30: 1,\n", - " 31: 1,\n", - " 36: 1}" - ] - }, - "execution_count": 48, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "age_buckets = bucketize(students_with_age, \"Age\")\n", - "dict(sorted({age:len(students) for age, students in age_buckets.items()}.items(), key = \\\n", - " lambda a: a[0]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Find whether 15 youngest students in the class are pet owners?" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['Yes',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'No',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'Yes']" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "students_with_age = [student_dict for student_dict in transformed_data \\\n", - " if student_dict[\"Age\"] != None]\n", - "[student_dict[\"Pet owner\"] for student_dict in sorted(students_with_age, \\\n", - " key = lambda s_dict: s_dict[\"Age\"])[:15]]" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions_template-checkpoint.ipynb b/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions_template-checkpoint.ipynb deleted file mode 100644 index 7ca2e93..0000000 --- a/f22/meena_lec_notes/lec-24/.ipynb_checkpoints/lec_24_comprehensions_template-checkpoint.ipynb +++ /dev/null @@ -1,739 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Comprehensions" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# import statements\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Review of lambdas\n", - "- lambda functions are a way to abstract a function reference\n", - "- lambdas are simple functions with:\n", - " - multiple possible parameters\n", - " - single expression line as the function body\n", - "- lambdas are useful abstractions for:\n", - " - mathematical functions\n", - " - lookup operations\n", - "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* parameters: expression" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's sort the menu in different ways\n", - "- whenever you need to custom sort a dictionary, you must convert dict to list of tuples\n", - "- recall that you can use items method (applicable only to a dictionary)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu = { \n", - " 'broccoli': 4.99,\n", - " 'orange': 1.19,\n", - " 'pie': 3.95, \n", - " 'donut': 1.25, \n", - " 'muffin': 2.25,\n", - " 'cookie': 0.79, \n", - " 'milk':1.65, \n", - " 'bread': 5.99} \n", - "menu" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using item names (keys)\n", - "- let's first solve this using extract function\n", - "- recall that extract function deals with one of the inner items in the outer data structure\n", - " - outer data structure is list\n", - " - inner data structure is tuple" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def extract(???):\n", - " return ???" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sorted(menu.items(), key = ???)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = extract))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using lambdas\n", - "- if you are having trouble thinking through the lambda solution directly:\n", - " - write an extract function\n", - " - then abstract it to a lambda" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = lambda ???: ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using prices (values)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: menu_tuple[???]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using length of item names (keys)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: len(menu_tuple[???])))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: menu_tuple[1], ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Sort menu using decreasing order of prices - v2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dict(sorted(menu.items(), key = lambda menu_tuple: ???))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Iterable\n", - "\n", - "- What is an iterable? Anything that you can write a for loop to iterate over is called as an iterable.\n", - "- Examples of iteratables:\n", - " - `list`, `str`, `tuple`, `range()` (any sequence)\n", - " - `dict`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## List comprehensions\n", - "\n", - "- concise way of generating a new list based on existing list item manipulation \n", - "- short syntax - easier to read, very difficult to debug\n", - "\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "- iteratble: reference to any iterable object instance\n", - "- conditional_expression: filters the values in the original list based on a specific requirement\n", - "- expression: can simply be val or some other transformation of val\n", - "- enclosing [ ] represents new list\n", - "\n", - "Best approach:\n", - "- write for clause first\n", - "- if condition expression next\n", - "- expression in front of for clause last" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Which animals are in all caps?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Recap: retain animals in all caps\n", - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "caps_animals = []\n", - "print(\"Original:\", animals)\n", - "\n", - "\n", - " \n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now let's solve the same problem using list comprehension\n", - "<pre>\n", - "new_list = [expression for val in iterable if conditional_expression]\n", - "</pre>\n", - "For the below example:\n", - "- iterable: animals variable (storing reference to a list object instance)\n", - "- conditional_expression: val.upper() == val\n", - "- expression: val itself" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# List comprehension version\n", - "print(\"Original:\", animals)\n", - "\n", - "caps_animals = ???\n", - "print(\"New list:\", caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Why is to tougher to debug?\n", - "- you cannot use a print function call in a comprehension\n", - "- you need to decompose each part and test it separately\n", - "- recommended to write the comprehension with a simpler example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Other than a badger, what animals can you see at Henry Vilas Zoo?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = ???\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we convert all of the animals to all caps?\n", - "- if clause is optional" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "all_caps_animals = ???\n", - "print(\"New list:\", all_caps_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Can we generate a list to store length of each animal name?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"Original:\", animals)\n", - "\n", - "animals_name_length = ???\n", - "print(\"New list:\", animals_name_length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Using if ... else ... in a list comprehension\n", - "- syntax changes slightly for if ... else ...\n", - "\n", - "<pre>\n", - "new_list = [expression if conditional_expression else alternate_expression for val in iterable ]\n", - "</pre>\n", - "\n", - "- when an item satifies the if clause, you don't execute the else clause\n", - " - expression is the item in new list when if condition is satified\n", - "- when an item does not satisfy the if clause, you execute the else clause\n", - " - alternate_expression is the item in new list when if condition is not satisfied\n", - " \n", - "- if ... else ... clauses need to come before for (not the same as just using if clause)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What if we only care about the badger? Replace non-badger animals with \"some animal\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "animals = [\"lion\", \"badger\", \"RHINO\", \"GIRAFFE\"]\n", - "print(\"Original:\", animals)\n", - "\n", - "non_badger_zoo_animals = ???\n", - "print(\"New list:\", non_badger_zoo_animals)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Dict comprehensions\n", - "- Version 1:\n", - "<pre>\n", - "{expression for val in iterable if condition}\n", - "</pre>\n", - "- expression has the form <pre>key: val</pre>\n", - "<br/>\n", - "- Version 2 --- the dict function call by passing list comprehension as argument:\n", - "<pre>dict([expression for val in iterable if condition])</pre>\n", - "- expression has the form <pre>(key, val)</pre>" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dict to map number to its square (for numbers 1 to 5)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "squares_dict = dict()\n", - "for val in range(1, 6):\n", - " squares_dict[val] = val * val\n", - "print(squares_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "square_dict = ???\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dict comprehension --- version 2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "square_dict = ???\n", - "print(square_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Tuple unpacking\n", - "- you can directly specific variables to unpack the items inside a tuple" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "\n", - "for tuple_item in scores_dict.items():\n", - " print(tuple_item)\n", - " \n", - "print(\"--------------------\")\n", - "\n", - "for key, val in scores_dict.items():\n", - " print(key, val)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### From square_dict, let's generate cube_dict" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "cube_dict = ???\n", - "print(cube_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert Madison *F temperature to *C\n", - "- <pre>C = 5 / 9 * (F - 32)</pre>" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "madison_fahrenheit = {'Jan': 26, 'Feb': 31, 'Mar': 43, 'Apr': 57, 'May': 68}\n", - "print(\"Original:\", madison_fahrenheit)\n", - "\n", - "madison_celsius = {key: ??? for key, val in madison_fahrenheit.items()}\n", - "print(\"New dict:\", madison_celsius)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Convert type of values in a dictionary" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": \"32\", \"Cindy\" : \"45\", \"Alice\": \"39\", \"Unknown\": \"None\"}\n", - "print(\"Original:\", scores_dict)\n", - "\n", - "updated_scores_dict = {??? for key, val in scores_dict.items()}\n", - "print(\"New dict:\", updated_scores_dict)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a dictionary to map each player to their max score" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n", - "{???: ??? for player, scores in scores_dict.items()}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - sorted + lambda" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Use sorted and lambda function to sort this list of dictionaries based on the score, from low to high" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores = [ {\"name\": \"Bob\", \"score\": 32} ,\n", - " {\"name\": \"Cindy\", \"score\" : 45}, \n", - " {\"name\": \"Alice\", \"score\": 39}\n", - " ]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, modify the lambda function part alone to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Now, go back to the previous lambda function definition and use sorted parameters to sort the list of dictionaries based on the score, from high to low" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice problems - comprehensions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Using range and raise10 functions, generate a list to store 10 to powers 1, 2, 3, 4, and 5" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list where each number is a square of the original nummber in numbers list" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numbers = [44, 33, 56, 21, 19]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of floats from vac_rates, that is rounded to 3 decimal points" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vac_rates = [23.329868, 51.28772, 76.12232, 17.2, 10.5]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Generate a new list of ints from words, that contains length of each word" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "words = ['My', 'very', 'educated', 'mother', 'just', 'served', 'us', 'noodles']\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a 2 dictionaries to map each player to their min and avg score" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "scores_dict = {\"Bob\": [18, 72, 61, 5, 83], \n", - " \"Cindy\" : [27, 11, 55, 73, 87], \n", - " \"Alice\": [16, 33, 42, 89, 90], \n", - " \"Meena\": [39, 93, 9, 3, 55]}\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/f22/meena_lec_notes/lec-24/cs220_survey_data.csv b/f22/meena_lec_notes/lec-24/cs220_survey_data.csv index 2ecab22..abfd53b 100644 --- a/f22/meena_lec_notes/lec-24/cs220_survey_data.csv +++ b/f22/meena_lec_notes/lec-24/cs220_survey_data.csv @@ -1,721 +1,993 @@ -Lecture,Age,Primary major,Other majors,Zip Code,Pizza topping,Pet owner,Runner,Sleep habit,Procrastinator -LEC002,19,Engineering: Mechanical,,53711,pepperoni,Yes,No,night owl,Maybe -LEC002,20,Science: Physics,"Astronomy-Physics, History",53726,pineapple,Yes,Yes,night owl,Yes -LEC001,20,Science: Chemistry,,53703,pepperoni,Yes,No,early bird,No -LEC004,19,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,night owl,No -LEC004,20,Other,Economics ,53715,mushroom,Yes,Yes,no preference,Maybe -LEC003,18,Statistics,,53706,Other,Yes,No,night owl,Yes -LEC003,18,Mathematics/AMEP,,53706,sausage,No,No,night owl,No -LEC004,18,Engineering: Biomedical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC003,19,Data Science,Stats,53715,pineapple,Yes,No,no preference,No -LEC003,19,Business: Finance,,53703,sausage,Yes,Yes,early bird,Yes -LEC003,18,Engineering: Mechanical,,53706,Other,No,No,no preference,No -LEC004,18,Other,I am undecided – thinking about Data Science Major,53706,basil/spinach,Yes,No,night owl,Maybe -LEC004,19,Engineering: Other,,53706,pepperoni,Yes,No,night owl,Maybe -LEC003,18,Statistics,psychology,53706,mushroom,No,No,night owl,Yes -LEC004,20,Statistics,Mathematics ,53726,pepperoni,Yes,Yes,early bird,Maybe -LEC004,20,Mathematics/AMEP,,53711,sausage,Yes,No,night owl,Yes -LEC003,18,Science: Physics,Data Science,53706,pepperoni,No,Yes,early bird,No -LEC003,19,Data Science,Economics,53715,pepperoni,No,Yes,no preference,Maybe -LEC003,19,Engineering: Mechanical,nuclear engineering,53706,sausage,Yes,No,night owl,Yes -LEC003,21,Science: Chemistry,,,green pepper,Yes,No,early bird,Maybe -LEC003,18,Engineering: Other,,53706,pepperoni,Yes,Yes,no preference,Yes -LEC003,,Engineering: Other,,,pineapple,Yes,No,early bird,Maybe -LEC002,20,Computer Science,Data Science,53706,basil/spinach,Yes,No,night owl,Maybe -LEC002,21,Science: Other,,53703,sausage,Yes,No,early bird,Maybe -LEC001,21,Computer Science,Data Science,53715,pepperoni,Yes,No,night owl,Maybe -LEC004,18,Engineering: Mechanical,,53706,pepperoni,Yes,No,early bird,Maybe -LEC002,18,Languages,Linguistics,53706,macaroni/pasta,Yes,Yes,night owl,Yes -LEC002,18,Engineering: Mechanical,,53706,Other,No,Yes,night owl,Maybe -LEC002,18,Other,,53706,none (just cheese),Yes,Yes,night owl,Yes -LEC001,19,Science: Other,,53706,mushroom,Yes,No,night owl,Yes -LEC001,18,Engineering: Biomedical,,,pepperoni,Yes,No,no preference,Maybe -LEC003,19,Engineering: Biomedical,,53706,none (just cheese),Yes,No,night owl,Maybe -LEC001,20,Science: Physics,Mathematics,53703,pineapple,Yes,No,early bird,No -LEC002,28,Science: Other,,53703,pineapple,Yes,Yes,night owl,Maybe -LEC001,18,Other,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,20,Engineering: Other,,53715,pepperoni,Yes,No,night owl,Yes -LEC001,19,Science: Physics,Life Science Communication,53706,pineapple,Yes,No,night owl,Yes -LEC003,18,Engineering: Biomedical,pre-medicine,53706,sausage,Yes,Yes,early bird,No -LEC003,,Engineering: Biomedical,,53706,none (just cheese),No,Yes,early bird,Yes -LEC001,21,Science: Other,,53711,pepperoni,Yes,No,night owl,No -LEC002,18,Engineering: Biomedical,,53706,sausage,Yes,No,no preference,No -LEC001,18,Engineering: Biomedical,,53706,macaroni/pasta,Yes,No,early bird,Yes -LEC004,21,Engineering: Biomedical,,53703,pepperoni,Yes,No,no preference,Yes -LEC004,18,Business: Information Systems,,53706,pepperoni,Yes,Yes,night owl,No -LEC001,19,Business: Actuarial,Data Science and Analytics,53706,pepperoni,Yes,Yes,night owl,No -LEC001,22,Engineering: Industrial,,,sausage,Yes,No,night owl,Yes -LEC003,20,Other,"data science, business",53703,mushroom,Yes,Yes,no preference,Maybe -LEC004,18,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,18,Engineering: Other,,53706,mushroom,No,No,early bird,No -LEC001,19,Data Science,Sports Journalism certificate,53703,pepperoni,Yes,Yes,no preference,No -LEC004,18,Data Science,,53706,none (just cheese),Yes,No,night owl,Yes -LEC002,20,Statistics,"Data Science, Math",53715,mushroom,No,No,night owl,No -LEC001,19,Engineering: Biomedical,,53706,mushroom,Yes,Yes,early bird,No -LEC003,20,Other,Data science certificate,,sausage,Yes,Yes,no preference,Yes -LEC003,20,Engineering: Industrial,Computer science,53719,sausage,No,No,early bird,Maybe -LEC003,,Computer Science,Minors in Data Science and Chicano and Latino Studies,53715,macaroni/pasta,No,Yes,night owl,Yes -LEC002,19,Computer Science,,,mushroom,Yes,No,no preference,No -LEC002,18,Engineering: Biomedical,,,pepperoni,Yes,No,night owl,Yes -LEC002,20,Business: Finance,Economics,53715,pepperoni,Yes,No,night owl,Yes -LEC002,19,Engineering: Biomedical,,53706,sausage,Yes,Yes,no preference,Maybe -LEC002,19,Engineering: Biomedical,,52706,pepperoni,Yes,Yes,early bird,No -LEC001,19,Science: Biology/Life,,53703,basil/spinach,Yes,No,night owl,Maybe -LEC002,19,Engineering: Mechanical,History,53706,none (just cheese),No,Yes,no preference,Yes -LEC002,21,Computer Science,Math,53715,sausage,Yes,No,night owl,Yes -LEC004,19,Data Science,Economics,53706,pepperoni,No,No,night owl,Yes -LEC001,18,Engineering: Mechanical,,53715,none (just cheese),Yes,Yes,no preference,Maybe -LEC004,18,Engineering: Biomedical,,53706,pineapple,Yes,No,night owl,Yes -LEC003,18,Other,Sociology,53706,pineapple,Yes,No,night owl,Yes -LEC004,18,Engineering: Biomedical,,53706,pepperoni,Yes,Yes,early bird,No -LEC001,23,Business: Other,,53705,pineapple,No,No,no preference,No -LEC004,18,Engineering: Biomedical,,53706,mushroom,Yes,Yes,no preference,Maybe -LEC001,18,Data Science,,53703,pepperoni,Yes,No,night owl,No -LEC001,19,Business: Finance,,53706,pineapple,No,No,night owl,Maybe -LEC004,19,Science: Biology/Life,"Environmental Sciences, Conservation Biology",53715,basil/spinach,Yes,No,no preference,No -LEC001,20,Computer Science,,53715,pepperoni,Yes,Yes,night owl,Yes -LEC004,18,Computer Science,Data Science,53706,none (just cheese),Yes,No,early bird,Yes -LEC003,18,Science: Other,,53706,pepperoni,Yes,No,night owl,Yes -LEC002,19,Engineering: Biomedical,,53706,sausage,Yes,Yes,no preference,Yes -LEC001,19,Computer Science,Economics,53715,sausage,Yes,No,no preference,Yes -LEC001,21,Other,,,mushroom,No,No,night owl,Maybe -LEC004,21,Data Science,,53703,none (just cheese),Yes,No,night owl,Yes -LEC002,20,Data Science,,53703,pineapple,Yes,Yes,early bird,Maybe -LEC002,18,Data Science,,53715,Other,Yes,No,early bird,No -LEC003,19,Mathematics/AMEP,Double major math and economics,,pepperoni,Yes,Yes,night owl,No -LEC003,18,Science: Biology/Life,,53706,none (just cheese),No,Yes,night owl,Yes -LEC003,20,Computer Science,Computer Engineering,,pepperoni,Yes,No,night owl,Maybe -LEC002,20,Engineering: Industrial,Maybe Data Science,53703,none (just cheese),Yes,No,night owl,Yes -LEC003,18,Data Science,Biochemistry,53706,basil/spinach,No,Yes,no preference,Yes -LEC003,19,Science: Other,,53706,Other,No,Yes,early bird,No -LEC003,20,Engineering: Mechanical,,53706,pepperoni,No,No,night owl,Maybe -LEC001,36,Other,,53705,sausage,No,No,no preference,Maybe -LEC003,18,Data Science,,53706,pineapple,Yes,No,early bird,No -LEC003,19,Engineering: Mechanical,,,pepperoni,Yes,No,no preference,No -LEC004,20,Science: Biology/Life,,53703,pepperoni,Yes,No,night owl,Yes -LEC001,22,Engineering: Biomedical,,53703,sausage,Yes,No,night owl,Yes -LEC002,18,Business: Information Systems,,53706,macaroni/pasta,Yes,Yes,no preference,Maybe -LEC001,18,Engineering: Other,,53703,basil/spinach,Yes,Yes,no preference,Yes -LEC002,19,Statistics,mathematics,53703,Other,No,Yes,night owl,Yes -LEC001,20,Engineering: Biomedical,,53715,pepperoni,Yes,No,early bird,Yes -LEC002,24,Science: Other,,53703,mushroom,Yes,No,night owl,Yes -LEC001,20,Computer Science,Data science,53715,pepperoni,Yes,Yes,night owl,No -LEC001,19,Mathematics/AMEP,Spanish,53715,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC003,20,Data Science,,53726,sausage,Yes,No,night owl,Maybe -LEC004,20,Other,,53713,pineapple,Yes,No,early bird,Maybe -LEC002,23,Engineering: Other,,53705,pineapple,Yes,No,night owl,Maybe -LEC001,21,Engineering: Mechanical,,53706,pepperoni,No,Yes,night owl,Yes -LEC003,21,Science: Biology/Life,,53726,basil/spinach,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,No -LEC004,19,Engineering: Other,,53706,sausage,Yes,No,night owl,Yes -LEC001,19,Science: Physics,,53706,Other,Yes,No,night owl,Maybe -LEC002,20,Engineering: Industrial,,53715,basil/spinach,Yes,No,night owl,Yes -LEC003,19,Science: Biology/Life,Data sciences ,53706,pineapple,Yes,Yes,early bird,No -LEC003,19,Other,undecided/exploring majors in science/math/tech,53706,macaroni/pasta,Yes,Yes,night owl,Maybe -LEC001,19,Engineering: Industrial,,53703,sausage,Yes,No,night owl,Yes -LEC003,20,Engineering: Industrial,,53703,sausage,Yes,Yes,night owl,Yes -LEC002,18,Other,,53706,pepperoni,Yes,No,no preference,Yes -LEC003,19,Business: Information Systems,Management and Human Resources ,53706,none (just cheese),No,No,night owl,No -LEC001,19,Computer Science,Computer engineering,53726,pepperoni,Yes,Yes,night owl,Yes -LEC001,18,Business: Finance,Minor: Data Science,53703,pepperoni,Yes,No,night owl,Maybe -LEC002,18,Engineering: Mechanical,,53706,Other,Yes,No,night owl,Yes -LEC004,18,Engineering: Mechanical,,53715,sausage,Yes,No,no preference,Maybe -LEC002,19,Engineering: Biomedical,,53715,pepperoni,Yes,No,night owl,Maybe -LEC002,22,Science: Other,,53715,sausage,Yes,Yes,night owl,Yes -LEC001,19,Other,Education Studies,53715,mushroom,No,No,night owl,Yes -LEC001,24,Business: Actuarial,,53713,sausage,Yes,No,night owl,Maybe -LEC001,18,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,25,Engineering: Industrial,,53705,pineapple,No,No,night owl,Maybe -LEC003,20,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,night owl,Yes -LEC003,18,Engineering: Mechanical,business,53706,pepperoni,Yes,Yes,night owl,Yes -LEC002,21,Engineering: Biomedical,,53703,basil/spinach,Yes,No,night owl,Maybe -LEC003,19,Computer Science,,53703,pepperoni,Yes,No,no preference,No -LEC003,18,Data Science,,53703,pepperoni,Yes,Yes,early bird,No -LEC001,19,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC003,18,Mathematics/AMEP,,52706,mushroom,Yes,Yes,night owl,No -LEC001,19,Data Science,,53706,macaroni/pasta,Yes,No,night owl,Maybe -LEC003,18,Business: Other,I wasn't sure what to answer in the question above because I'm a Freshman and I'm Pre-Business.,53703,none (just cheese),Yes,No,night owl,Yes -LEC001,21,Data Science,,53715,pepperoni,Yes,Yes,early bird,No -LEC003,18,Computer Science,,53706-1203,Other,Yes,No,night owl,Yes -LEC001,20,Computer Science,,53706,pepperoni,No,No,night owl,Yes -LEC003,19,Business: Information Systems,,53706,sausage,Yes,Yes,no preference,No -LEC001,21,Business: Actuarial,Risk Management and Insurance,53715,pineapple,Yes,No,night owl,Maybe -LEC003,19,Science: Biology/Life,Data Science,53706,pepperoni,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC004,20,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,early bird,No -LEC002,21,Other,Economics with Math Emphasis,53703,pepperoni,Yes,No,no preference,Yes -LEC001,20,Business: Other,Certificates in Data Science and Digital Studies,53715,sausage,Yes,Yes,early bird,Maybe -LEC001,18,Engineering: Mechanical,,,pineapple,No,No,no preference,Yes -LEC003,19,Computer Science,,53706,pepperoni,No,Yes,no preference,Maybe -LEC003,18,Statistics,Data Science ,53706,pepperoni,Yes,No,night owl,No -LEC004,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC002,26,Engineering: Other,,53705,Other,Yes,Yes,early bird,Yes -LEC001,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,18,Engineering: Mechanical,,53706,basil/spinach,Yes,No,night owl,Yes -LEC001,27,Computer Science,,53703,sausage,No,No,early bird,Maybe -LEC003,20,Engineering: Biomedical,,,mushroom,Yes,No,early bird,Yes -LEC001,18,Statistics,,,sausage,Yes,No,night owl,Maybe -LEC004,19,Statistics,Considering data science as my secondary field of study.,53726,pepperoni,Yes,No,night owl,Yes -LEC001,19,Engineering: Industrial,,,basil/spinach,Yes,Yes,night owl,Yes -LEC001,20,Other,,53706,macaroni/pasta,Yes,Yes,night owl,Maybe -LEC004,20,Other,,53703,sausage,Yes,Yes,night owl,Yes -LEC001,21,Engineering: Other,,53715,pepperoni,No,No,night owl,Yes -LEC004,20,Engineering: Mechanical,,53711,mushroom,Yes,No,night owl,Yes -LEC003,20,Business: Information Systems,,53715,pepperoni,Yes,No,night owl,Yes -LEC003,21,Engineering: Other,,,mushroom,Yes,No,night owl,Yes -LEC001,24,Statistics,data science,53703,basil/spinach,Yes,No,early bird,No -LEC003,19,Computer Science,math,53706,basil/spinach,Yes,No,early bird,Maybe -LEC004,21,Computer Science,,53715,pepperoni,Yes,Yes,early bird,No -LEC002,21,Mathematics/AMEP,,53715,pepperoni,Yes,No,early bird,Maybe -LEC001,,Science: Biology/Life,,,Other,Yes,Yes,early bird,No -LEC003,18,Engineering: Mechanical,Computer Science Certificate,53706,basil/spinach,No,Yes,early bird,No -LEC002,18,Other,Data Science,53706,basil/spinach,Yes,No,early bird,No -LEC003,18,Business: Information Systems,Data Science Certificate,53706,basil/spinach,Yes,Yes,early bird,No -LEC002,19,Engineering: Industrial,,53706,sausage,Yes,No,early bird,Maybe -LEC004,18,Engineering: Mechanical,,53706,sausage,Yes,No,night owl,Maybe -LEC001,22,Science: Other,Mathematics,53726,pepperoni,Yes,Yes,no preference,Yes -LEC001,18,Engineering: Industrial,,53706,mushroom,No,Yes,early bird,Yes -LEC002,19,Engineering: Mechanical,,53706,green pepper,No,Yes,night owl,No -LEC003,18,Statistics,mathematics,53706,mushroom,Yes,No,night owl,No -LEC003,19,Other,,53706,pepperoni,Yes,Yes,no preference,Yes -LEC003,20,Other,"Education, Psychology, Data Science",53715,pineapple,Yes,Yes,no preference,Yes -LEC003,19,Statistics,,53703,pepperoni,Yes,No,early bird,Maybe -LEC003,20,Data Science,,53703,macaroni/pasta,Yes,Yes,night owl,Yes -LEC004,20,Business: Actuarial,,53706,pepperoni,Yes,No,early bird,No -LEC003,20,Data Science,,53703,mushroom,Yes,No,night owl,Yes -LEC003,19,Mathematics/AMEP,finance,53706,sausage,No,Yes,early bird,Maybe -LEC003,21,Other,Political Science,53703,pepperoni,Yes,No,night owl,Maybe -LEC002,19,Engineering: Mechanical,,53706,basil/spinach,Yes,Yes,night owl,Maybe -LEC001,19,Mathematics/AMEP,Data Science,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC001,18,Computer Science,Information Systems (Maybe),53706,sausage,Yes,No,early bird,Yes -LEC001,20,Business: Actuarial,Business: Risk Management,53703,pepperoni,Yes,No,early bird,Yes -LEC002,26,Engineering: Other,,53705,mushroom,No,No,night owl,Maybe -LEC001,18,Business: Information Systems,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,23,Engineering: Other,Environmental Science,53703,mushroom,Yes,Yes,early bird,Maybe -LEC003,18,Science: Biology/Life,,53706,pineapple,No,No,early bird,Yes -LEC002,18,Engineering: Biomedical,,53706,pepperoni,Yes,No,no preference,No -LEC001,18,Other,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,Data Science,53726,sausage,Yes,No,no preference,Yes -LEC003,20,Data Science,,53715,pepperoni,Yes,No,night owl,Yes -LEC003,19,Engineering: Biomedical,,53706,pepperoni,No,Yes,early bird,No -LEC004,19,Business: Information Systems,,53715,none (just cheese),Yes,No,night owl,Yes -LEC001,20,Computer Science,,53703,mushroom,Yes,Yes,early bird,Maybe -LEC002,18,Data Science,,53703,none (just cheese),Yes,No,night owl,Yes -LEC004,19,Engineering: Mechanical,,53575,sausage,Yes,No,night owl,Maybe -LEC004,20,Business: Other,Information Systems,53703,sausage,Yes,Yes,no preference,Maybe -LEC003,18,Engineering: Biomedical,,53715,pineapple,Yes,No,no preference,Yes -LEC004,19,Engineering: Mechanical,,53706,mushroom,Yes,No,early bird,Maybe -LEC003,,Engineering: Biomedical,Certificate in French,,macaroni/pasta,Yes,Yes,night owl,No -LEC003,21,Business: Information Systems,,53703,pepperoni,Yes,Yes,night owl,Maybe -LEC001,,Data Science,,5 3706,mushroom,Yes,No,night owl,No -LEC004,19,Engineering: Biomedical,,53715,none (just cheese),Yes,Yes,no preference,Yes -LEC002,19,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,night owl,No -LEC003,20,Computer Science,,53711,sausage,No,No,night owl,Maybe -LEC004,21,Science: Biology/Life,,53711,sausage,Yes,Yes,night owl,No -LEC003,21,Other,"Psychology, Chinese",53703,Other,Yes,Yes,night owl,Maybe -LEC003,20,Data Science,Minor - Comp Sci,53703,basil/spinach,Yes,Yes,no preference,Yes -LEC004,21,Science: Other,"Global Health is main major, possibly on the premed track, Data Science Certificate",53715,pineapple,Yes,Yes,early bird,No -LEC003,20,Engineering: Mechanical,,53726,pepperoni,Yes,Yes,night owl,Yes -LEC001,22,Science: Biology/Life,,53703,green pepper,Yes,No,night owl,Yes -LEC002,19,Science: Biology/Life,,53703,pepperoni,Yes,No,night owl,Maybe -LEC004,21,Engineering: Biomedical,,53715,green pepper,Yes,Yes,night owl,Maybe -LEC002,20,Business: Finance,Real Estate,53703,pepperoni,Yes,Yes,night owl,No -LEC004,21,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,night owl,Yes -LEC002,19,Engineering: Industrial,"not positive on IE, maybe ME",53703,pepperoni,Yes,No,night owl,Maybe -LEC004,18,Engineering: Biomedical,,53706,mushroom,Yes,No,early bird,No -LEC003,19,Business: Actuarial,Data Science,53706,pepperoni,Yes,No,night owl,Yes -LEC001,24,Other,Life Science Communications,53703,pineapple,Yes,No,night owl,No -LEC004,22,Engineering: Other,,53715,pepperoni,No,Yes,early bird,No -LEC002,18,Engineering: Mechanical,,53715,pepperoni,Yes,Yes,night owl,Maybe -LEC004,19,Data Science,business: finance,53703,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Business: Other,"Economics, Data Science",53703,pepperoni,Yes,Yes,early bird,No -LEC004,18,Engineering: Other,,53706,pineapple,Yes,Yes,night owl,Maybe -LEC003,19,Engineering: Mechanical,,53706,none (just cheese),Yes,No,early bird,No -LEC002,18,Engineering: Mechanical,,53706,Other,Yes,Yes,early bird,No -LEC001,19,Other,,53706,green pepper,Yes,Yes,night owl,Yes -LEC004,18,Engineering: Biomedical,,53706,basil/spinach,Yes,Yes,no preference,No -LEC001,19,Business: Information Systems,,53726,green pepper,No,Yes,night owl,Maybe -LEC001,18,Engineering: Biomedical,,53706,sausage,Yes,No,night owl,Yes -LEC003,19,Engineering: Industrial,,53715,pepperoni,No,Yes,early bird,Yes -LEC002,27,Business: Information Systems,,53703,mushroom,No,Yes,night owl,No -LEC001,30,Business: Other,,57305,pineapple,Yes,No,night owl,Yes -LEC004,18,Engineering: Biomedical,Neuroscience/pre-med,53706,none (just cheese),Yes,No,night owl,Yes -LEC002,20,Data Science,,53703,mushroom,No,No,early bird,Yes -LEC001,19,Data Science,,53706,Other,Yes,Yes,no preference,Maybe -LEC001,22,Engineering: Biomedical,,53706,sausage,Yes,No,night owl,Yes -LEC003,20,Data Science,,,mushroom,Yes,No,no preference,Maybe -LEC003,20,Other,Economics with Math emphasis,53703,pineapple,No,No,early bird,Maybe -LEC002,20,Computer Science,Data Science,53706,basil/spinach,Yes,No,no preference,Yes -LEC001,24,Science: Biology/Life,,53706,mushroom,Yes,Yes,early bird,No -LEC004,20,Business: Information Systems,Real Estate,53703,pepperoni,Yes,No,night owl,Maybe -LEC001,20,Data Science,Economics,53703,sausage,Yes,No,no preference,Maybe -LEC002,20,Engineering: Mechanical,,53703,pepperoni,Yes,Yes,night owl,Maybe -LEC004,20,Engineering: Mechanical,,53715,pineapple,Yes,Yes,night owl,No -LEC004,20,Science: Biology/Life,Data Science Certificate (maybe) ,53703,sausage,Yes,Yes,night owl,Maybe -LEC004,18,Engineering: Mechanical,,19002,pepperoni,Yes,No,no preference,Yes -LEC001,19,Engineering: Other,,53706,pepperoni,Yes,No,no preference,Maybe -LEC002,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,early bird,Maybe -LEC004,19,Computer Science,Mathematics,53706,pineapple,Yes,No,no preference,Maybe -LEC003,18,Business: Information Systems,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,19,Science: Physics,,53706,pineapple,Yes,Yes,night owl,Maybe -LEC004,18,Other,,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC001,25,Engineering: Other,"Architect, Landscape Planner",,mushroom,Yes,Yes,early bird,No -LEC001,21,Engineering: Mechanical,Physics,53706,mushroom,No,Yes,no preference,Maybe -LEC004,20,Other,"I major in economics, hoping to obtain a data science certificate.",53703,pepperoni,Yes,No,night owl,Yes -LEC001,20,Data Science,Economics,53703,none (just cheese),No,Yes,night owl,Maybe -LEC001,21,Science: Other,,53703,mushroom,Yes,No,night owl,Yes -LEC002,18,Data Science,,53706,pepperoni,Yes,No,night owl,No -LEC002,24,Business: Other,,53711,sausage,Yes,No,night owl,Yes -LEC001,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC003,20,Business: Actuarial,,53703,pepperoni,No,Yes,night owl,No -LEC001,21,Data Science,Economics,53715,pineapple,Yes,No,night owl,Maybe -LEC001,23,Other,"Marketing, Data science ",,none (just cheese),No,No,early bird,Maybe -LEC002,22,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,night owl,No -LEC003,18,Computer Science,,53703,sausage,Yes,No,night owl,Yes -LEC003,19,Science: Physics,Astronomy-Physics ,53706,pepperoni,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53715,pepperoni,Yes,No,early bird,No -LEC001,18,Data Science,,53706,pepperoni,Yes,Yes,early bird,Yes -LEC001,18,Business: Information Systems,,53706,pepperoni,No,No,night owl,Yes -LEC002,20,Mathematics/AMEP,data and risk analysis (data science),53726,pineapple,Yes,No,night owl,Yes -LEC001,18,Other,,53706,mushroom,Yes,No,no preference,Yes -LEC002,20,Science: Biology/Life,Economics with Math Emphasis,53703,pepperoni,Yes,No,early bird,Yes -LEC001,18,Data Science,,53706,none (just cheese),Yes,No,night owl,Yes -LEC001,,Statistics,Econ,,pineapple,No,No,night owl,Maybe -LEC003,19,Engineering: Biomedical,,53706,pineapple,Yes,No,night owl,Yes -LEC003,18,Engineering: Mechanical,,53706,Other,Yes,Yes,night owl,Yes -LEC003,18,Engineering: Biomedical,,53089,pepperoni,Yes,No,night owl,Yes -LEC003,18,Mathematics/AMEP,,53703,sausage,No,No,no preference,Maybe -LEC001,18,Data Science,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Data Science,,53706,pepperoni,Yes,No,early bird,Yes -LEC003,21,Engineering: Biomedical,,53726,sausage,Yes,No,early bird,Maybe -LEC004,22,Business: Other,,53703,green pepper,Yes,Yes,night owl,Yes -LEC002,19,Engineering: Mechanical,computer science,53706,pineapple,Yes,Yes,night owl,Maybe -LEC004,21,Science: Biology/Life,,53703,sausage,Yes,No,early bird,No -LEC002,18,Engineering: Other,,53706,sausage,Yes,Yes,night owl,Maybe -LEC001,20,Data Science,Economics,53703,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Engineering: Industrial,,53703,pepperoni,Yes,Yes,early bird,Maybe -LEC003,21,Computer Science,no,53703,pineapple,Yes,No,night owl,No -LEC002,20,Engineering: Mechanical,,53706,mushroom,Yes,No,night owl,Yes -LEC003,21,Business: Finance,,53715,pepperoni,Yes,No,night owl,Yes -LEC001,20,Science: Other,,53703,Other,Yes,Yes,night owl,Maybe -LEC001,20,Engineering: Other,,53715,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Engineering: Biomedical,,53706,green pepper,Yes,Yes,early bird,No -LEC002,19,Engineering: Mechanical,"German Certificate, Theatre Certificate",53706,pepperoni,Yes,No,night owl,Yes -LEC001,20,Engineering: Biomedical,,53703,pepperoni,Yes,No,night owl,Yes -LEC001,19,Statistics,,53715,sausage,Yes,No,night owl,Yes -LEC001,18,Engineering: Industrial,,53706,none (just cheese),Yes,No,night owl,Maybe -LEC004,22,Data Science,Economics,53703,pepperoni,Yes,No,night owl,Maybe -LEC001,18,Other,,53703,pepperoni,Yes,No,night owl,Yes -LEC002,19,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC001,23,Other,Biological Anthropology,53705,none (just cheese),Yes,No,early bird,Yes -LEC001,19,Engineering: Biomedical,,53706,pineapple,Yes,Yes,no preference,Maybe -LEC004,19,Business: Actuarial,econ,53715,sausage,Yes,No,night owl,Yes -LEC001,18,Engineering: Mechanical,,53703,macaroni/pasta,Yes,No,night owl,Yes -LEC002,18,Business: Other,,53706,mushroom,No,No,night owl,Maybe -LEC002,20,Other,,53703,mushroom,Yes,Yes,no preference,Yes -LEC002,19,Business: Actuarial,,53703,Other,Yes,No,no preference,Maybe -LEC001,21,Business: Other,,53715,pepperoni,Yes,No,night owl,Yes -LEC001,21,Business: Other,econ with math emphasis,53715,mushroom,Yes,Yes,night owl,Maybe -LEC004,21,Science: Biology/Life,,53703,none (just cheese),Yes,No,night owl,Maybe -LEC004,22,Other,"Psychology, communications",53715,basil/spinach,Yes,No,night owl,Yes -LEC003,18,Statistics,,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC001,20,Statistics,,53703,pepperoni,Yes,Yes,night owl,Maybe -LEC002,21,Data Science,,,pepperoni,Yes,Yes,no preference,Maybe -LEC001,18,Engineering: Biomedical,,,sausage,Yes,Yes,early bird,No -LEC003,20,Statistics,,53706,sausage,Yes,No,night owl,No -LEC002,21,Business: Other,,53703,pineapple,Yes,Yes,night owl,Maybe -LEC001,22,Data Science,,53715,pineapple,Yes,Yes,night owl,Maybe -LEC003,25,Computer Science,,53705,mushroom,Yes,No,night owl,Yes -LEC004,20,Other,,53715,pepperoni,Yes,Yes,early bird,Yes -LEC002,19,Computer Science,"ds,econ",53711,Other,Yes,No,night owl,No -LEC002,18,Other,,53706,pepperoni,No,No,night owl,Yes -LEC002,21,Business: Actuarial,Management,53706,pepperoni,Yes,No,night owl,Yes -LEC001,19,Business: Finance,Data science,53703,pepperoni,No,No,no preference,Maybe -LEC003,18,Engineering: Mechanical,,53703,pineapple,Yes,Yes,no preference,No -LEC001,21,Business: Other,"Consumer Behavior & Marketplace Studies, Data Science",53703,pepperoni,Yes,No,night owl,No -LEC002,20,Business: Finance,,53715,sausage,Yes,No,night owl,Yes -LEC001,19,Other,Psychology,53703,pepperoni,No,Yes,night owl,Yes -LEC003,18,Engineering: Biomedical,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,19,Business: Information Systems,,53711,sausage,Yes,No,night owl,No -LEC003,21,Computer Science,,53715,sausage,No,Yes,early bird,Yes -LEC004,20,Business: Other,,53703,pineapple,Yes,Yes,early bird,Yes -LEC001,,Other,,53706,pineapple,Yes,No,no preference,Maybe -LEC001,18,Statistics,economics,53703,pineapple,Yes,No,no preference,Yes -LEC003,19,Business: Finance,,53706,mushroom,Yes,No,night owl,Maybe -LEC001,18,Computer Science,Data Science,53706,mushroom,No,No,night owl,Maybe -LEC003,20,Statistics,,53703,pepperoni,Yes,No,night owl,Yes -LEC002,19,Engineering: Biomedical,,,macaroni/pasta,Yes,No,night owl,Yes -LEC003,19,Data Science,,53715,green pepper,Yes,No,early bird,Maybe -LEC001,19,Other,Psychology,53703,pepperoni,Yes,Yes,night owl,Maybe -LEC003,21,Business: Finance,Economics,53703,pepperoni,Yes,No,night owl,Maybe -LEC002,24,Engineering: Other,,53703,sausage,Yes,No,night owl,Yes -LEC003,19,Engineering: Industrial,,53703,pepperoni,Yes,Yes,no preference,Maybe -LEC002,20,Engineering: Other,"urban & regional planning, environmental engineering, data science",53706-1406,macaroni/pasta,Yes,Yes,night owl,Yes -LEC003,23,Engineering: Other,,53705,pepperoni,No,Yes,night owl,Yes -LEC001,19,Science: Biology/Life,,53703,pepperoni,Yes,No,early bird,No -LEC001,18,Data Science,,53706,basil/spinach,Yes,No,night owl,Maybe -LEC003,19,Business: Information Systems,,53703,macaroni/pasta,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC004,18,Science: Biology/Life,,53706,pepperoni,Yes,Yes,early bird,No -LEC003,27,Science: Biology/Life,,53705,mushroom,Yes,No,early bird,Maybe -LEC004,,Computer Science,,53715,pepperoni,Yes,No,night owl,Yes -LEC004,20,Engineering: Biomedical,,53715,pepperoni,Yes,Yes,early bird,No -LEC001,18,Computer Science,,53706,none (just cheese),No,Yes,night owl,Yes -LEC004,17,Science: Biology/Life,Data science certificate,53706,pepperoni,Yes,No,no preference,Maybe -LEC002,19,Data Science,"Econ, data science",53715,Other,Yes,No,night owl,Maybe -LEC001,18,Computer Science,Data Science,53706,mushroom,No,No,night owl,Yes -LEC002,18,Data Science,Economics,,pineapple,No,Yes,no preference,Yes -LEC002,18,Engineering: Industrial,,53703-1104,sausage,Yes,No,night owl,Maybe -LEC001,20,Business: Actuarial,Risk Management & Insurance,53703,pepperoni,Yes,No,early bird,No -LEC001,19,Data Science,,53715,mushroom,Yes,Yes,no preference,Maybe -LEC001,18,Engineering: Mechanical,,53706-1127,pepperoni,Yes,Yes,night owl,Yes -LEC003,18,Engineering: Other,,53703,Other,No,Yes,early bird,No -LEC001,24,Science: Other,data science,53715,pepperoni,Yes,Yes,early bird,Yes -LEC004,19,Engineering: Biomedical,,53715,green pepper,Yes,No,early bird,Yes -LEC003,20,Engineering: Biomedical,,53703,pepperoni,Yes,Yes,early bird,Maybe -LEC003,21,Mathematics/AMEP,Biochemistry,53715,none (just cheese),Yes,Yes,early bird,No -LEC003,20,Business: Other,,53706,sausage,Yes,No,night owl,Maybe -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,no preference,Yes -LEC003,21,Engineering: Industrial,,53711,basil/spinach,No,Yes,night owl,Yes -LEC001,20,Engineering: Industrial,,53703,pepperoni,Yes,Yes,no preference,No -LEC003,18,Engineering: Industrial,,53706,sausage,Yes,Yes,night owl,No -LEC003,20,Science: Biology/Life,Global Health,55416,pineapple,Yes,Yes,night owl,Yes -LEC003,18,Engineering: Biomedical,,53706,basil/spinach,No,No,no preference,Maybe -LEC003,19,Business: Other,,53706,sausage,Yes,No,night owl,Yes -LEC003,18,Engineering: Industrial,,53706,green pepper,Yes,Yes,night owl,Yes -LEC004,20,Data Science,Economics - math emphasis,53703,pepperoni,Yes,No,no preference,Yes -LEC003,19,Business: Information Systems," Operations, Technology, Management",53715,pepperoni,Yes,No,night owl,Maybe -LEC004,21,Engineering: Other,,53706,pineapple,No,Yes,early bird,No -LEC003,19,Engineering: Mechanical,,53715,Other,Yes,No,early bird,No -LEC003,20,Computer Science,Data Science,53703,none (just cheese),No,Yes,night owl,Maybe -LEC003,18,Science: Biology/Life,Data science,53706,sausage,Yes,No,night owl,No -LEC004,20,Engineering: Mechanical,,53715,macaroni/pasta,Yes,Yes,night owl,Yes -LEC002,,Business: Other,Double Business Major (Supply Chain and Business Management),53703,basil/spinach,Yes,No,night owl,Maybe -LEC003,18,Business: Finance,,53715,none (just cheese),No,Yes,night owl,Yes -LEC002,20,Engineering: Industrial,,53703,pepperoni,Yes,Yes,night owl,Yes -LEC001,22,Data Science,Stat or CS,53705,basil/spinach,Yes,Yes,early bird,No -LEC003,20,Business: Information Systems,"International Business, French",53703,basil/spinach,Yes,Yes,early bird,No -LEC004,19,Engineering: Other,,53706,none (just cheese),Yes,Yes,night owl,Maybe -LEC002,20,Other,ECONOMICS,53715,none (just cheese),Yes,Yes,night owl,Maybe -LEC004,19,Engineering: Mechanical, ,53715,pepperoni,Yes,No,night owl,Maybe -LEC004,19,Engineering: Mechanical,,53715,pepperoni,Yes,Yes,no preference,Yes -LEC004,20,Statistics,,53703,pepperoni,Yes,No,early bird,Yes -LEC001,19,Business: Actuarial,RMI,53706,basil/spinach,Yes,Yes,night owl,Yes -LEC001,20,Engineering: Biomedical,,53703,sausage,No,Yes,night owl,Yes -LEC004,19,Engineering: Biomedical,,53706,basil/spinach,Yes,No,early bird,Yes -LEC003,18,Data Science,,53706,none (just cheese),Yes,No,night owl,Maybe -LEC001,21,Computer Science,,53703,Other,Yes,Yes,night owl,Maybe -LEC001,19,Engineering: Industrial,,53706,pepperoni,Yes,No,night owl,No -LEC004,20,Science: Other,,53713,pineapple,Yes,Yes,night owl,Maybe -LEC004,18,Data Science,,53706,macaroni/pasta,Yes,No,night owl,Yes -LEC004,20,Engineering: Industrial,NA,54636,macaroni/pasta,Yes,Yes,early bird,Maybe -LEC001,19,Computer Science,,53711,mushroom,Yes,No,night owl,Yes -LEC004,19,Computer Science,,53711,sausage,No,No,night owl,Maybe -LEC004,19,Engineering: Biomedical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC004,19,Engineering: Mechanical,,53711,macaroni/pasta,Yes,No,night owl,Yes -LEC004,19,Engineering: Mechanical,,53597,pepperoni,No,Yes,night owl,No -LEC004,18,Engineering: Biomedical,,53706,sausage,Yes,Yes,night owl,Maybe -LEC004,18,Computer Science,Data science,53706,basil/spinach,No,Yes,no preference,Maybe -LEC004,21,Engineering: Biomedical,,53703,sausage,Yes,Yes,night owl,Yes -LEC004,19,Business: Information Systems,Accounting,53706,mushroom,Yes,No,night owl,No -LEC004,18,Engineering: Other,,53706,sausage,Yes,Yes,night owl,Yes -LEC004,20,Data Science,,53715,Other,Yes,No,night owl,Yes -LEC004,18,Engineering: Mechanical,,53706,mushroom,Yes,Yes,night owl,Yes -LEC004,18,Engineering: Mechanical,,53706,macaroni/pasta,Yes,Yes,no preference,Maybe -LEC001,18,Engineering: Biomedical,,53706,Other,No,No,night owl,Maybe -LEC004,19,Business: Finance,Industrial Engineering,53706,sausage,Yes,No,night owl,Maybe -LEC001,18,Business: Other,Main one is economics and data science,53706,pepperoni,No,No,no preference,Maybe -LEC004,18,Engineering: Industrial,,83001,sausage,Yes,Yes,night owl,Yes -LEC004,20,Engineering: Biomedical,,53715,pepperoni,Yes,Yes,night owl,Maybe -LEC004,18,Engineering: Mechanical,,53706,none (just cheese),No,No,night owl,Yes -LEC004,20,Other,,53715,sausage,No,No,night owl,Maybe -LEC004,19,Business: Information Systems,Business: Supply Chain Management,53703,pepperoni,Yes,No,no preference,Maybe -LEC004,20,Other,,53703,basil/spinach,Yes,No,night owl,Yes -LEC004,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC004,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,27,Computer Science,,53711,mushroom,Yes,Yes,no preference,Yes -LEC004,19,Business: Actuarial,,53706-1188,sausage,Yes,No,no preference,Yes -LEC004,21,Other,,53703,pepperoni,Yes,No,night owl,Yes -LEC001,19,Business: Other,,53703,pepperoni,Yes,No,no preference,Maybe -LEC004,18,Business: Finance,Data Science,53706,basil/spinach,Yes,No,night owl,Yes -LEC004,18,Science: Physics,,53706,mushroom,Yes,No,night owl,Yes -LEC002,19,Mathematics/AMEP,Actuarial Science,53706,sausage,Yes,Yes,night owl,Yes -LEC004,19,Business: Finance,data science,53706,pepperoni,Yes,Yes,no preference,Maybe -LEC002,19,Data Science,"Electrical engineering, physics",53703,none (just cheese),Yes,No,night owl,Yes -LEC004,21,Engineering: Biomedical,History Certificate ,53715,green pepper,Yes,No,no preference,Maybe -LEC001,19,Business: Finance,,53703,sausage,Yes,Yes,night owl,Maybe -LEC001,18,Business: Finance,,53703,pepperoni,Yes,No,night owl,Yes -LEC004,21,Engineering: Mechanical,Mechanical Engineering ,53703,green pepper,No,No,no preference,No -LEC004,19,Business: Information Systems,,53706,pepperoni,Yes,Yes,no preference,Maybe -LEC002,18,Computer Science,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC001,21,Computer Science,,43706,mushroom,Yes,Yes,no preference,Yes -LEC002,20,Business: Finance,Data Science,53703,pepperoni,No,Yes,no preference,No -LEC002,20,Engineering: Biomedical,,53703,pineapple,Yes,Yes,early bird,Maybe -LEC001,19,Business: Actuarial,risk management and insurance,53711,pepperoni,No,No,night owl,Yes -LEC002,21,Other,"Linguistics, Communication Sciences and Disorders",53715,green pepper,Yes,Yes,night owl,No -LEC001,19,Engineering: Mechanical,,53706,none (just cheese),Yes,Yes,night owl,Yes -LEC002,18,Engineering: Mechanical,,53706,macaroni/pasta,Yes,Yes,night owl,Yes -LEC001,19,Data Science,,53703,pineapple,Yes,No,night owl,Yes -LEC001,18,Science: Biology/Life,"Either stats, data science, or math (undecided)",53706,macaroni/pasta,Yes,Yes,night owl,Yes -LEC001,19,Data Science,Mathematics,53703,green pepper,Yes,Yes,night owl,Maybe -LEC001,23,Business: Other,,53711,pineapple,Yes,No,night owl,Maybe -LEC001,20,Data Science,economics,53703,none (just cheese),Yes,No,early bird,Yes -LEC001,18,Computer Science,Planning on Data Sci but unsure,53708,macaroni/pasta,Yes,No,night owl,Yes -LEC002,18,Science: Other,,53706,pepperoni,Yes,No,early bird,Maybe -LEC001,18,Computer Science,,53706,green pepper,Yes,Yes,night owl,Yes -LEC001,19,Statistics,,53703,pineapple,Yes,No,night owl,No -LEC001,20,Computer Science,Data Science,53703,pepperoni,Yes,Yes,no preference,Yes -LEC001,19,Business: Information Systems,,53706,basil/spinach,Yes,No,night owl,Yes -LEC001,19,Data Science,,53703,pineapple,No,Yes,night owl,Maybe -LEC001,18,Engineering: Mechanical,,53706,macaroni/pasta,Yes,Yes,night owl,No -LEC001,18,Data Science,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,19,Engineering: Industrial,Data Science,53706,green pepper,Yes,No,night owl,Yes -LEC004,21,Other,,53726,sausage,Yes,No,night owl,Yes -LEC001,19,Engineering: Mechanical,,53704,sausage,Yes,No,no preference,Yes -LEC001,18,Computer Science,Data Science,53706,pepperoni,No,Yes,no preference,No -LEC001,19,Other,,53705,pepperoni,No,No,night owl,Yes -LEC001,21,Computer Science,data science,53706,pineapple,No,No,night owl,Yes -LEC001,19,Statistics,,53703,sausage,Yes,No,night owl,Maybe -LEC001,19,Science: Chemistry,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,20,Other,legal study,53705,sausage,Yes,No,no preference,Maybe -LEC001,19,Statistics,biochemistry,53703,pineapple,Yes,No,no preference,Yes -LEC001,22,Engineering: Biomedical,,,basil/spinach,Yes,Yes,night owl,Maybe -LEC001,19,Engineering: Industrial,,53706,sausage,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53711,sausage,Yes,No,no preference,Yes -LEC001,19,Engineering: Mechanical,,53703,none (just cheese),Yes,Yes,night owl,Yes -LEC001,21,Computer Science,Computer Engineering,53703,sausage,No,No,night owl,Yes -LEC003,20,Engineering: Mechanical,,53703,sausage,No,No,night owl,No -LEC001,21,Computer Science,Electrical Engineering,53715,pepperoni,Yes,Yes,night owl,Maybe -LEC001,19,Engineering: Industrial,Business,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC001,18,Other,,53706,none (just cheese),Yes,No,night owl,Yes -LEC001,18,Science: Biology/Life,"Data Science Minor, French",53706,pineapple,Yes,No,night owl,Yes -LEC001,21,Other,,53703,mushroom,Yes,Yes,early bird,Yes -LEC001,22,Computer Science,DS,53711,Other,Yes,No,no preference,Maybe -LEC003,19,Other,,53703,pepperoni,No,No,no preference,Yes -LEC001,19,Data Science,,53706,Other,No,Yes,early bird,Yes -LEC002,18,Engineering: Mechanical,Minor in Business ,53706,sausage,Yes,No,no preference,Yes -LEC001,21,Engineering: Other,Civil Engineering,53715,Other,No,Yes,no preference,Yes -LEC002,19,Statistics,Economics,53703,pepperoni,Yes,No,night owl,Yes -LEC002,20,Business: Actuarial,,53703,sausage,Yes,No,night owl,No -LEC001,24,Business: Other,,53703,green pepper,No,No,early bird,Maybe -LEC004,18,Engineering: Biomedical,,53706,sausage,Yes,No,no preference,No -LEC001,23,Other,,53703,pineapple,Yes,No,night owl,Yes -LEC003,19,Statistics,,53706,none (just cheese),Yes,Yes,early bird,Yes -LEC002,18,Other,,53706,basil/spinach,Yes,No,night owl,Yes -LEC001,20,Statistics,,53703,mushroom,Yes,Yes,night owl,Yes -LEC004,18,Computer Science,Data Science,,none (just cheese),Yes,Yes,night owl,Yes -LEC002,19,Engineering: Mechanical,,53706,Other,Yes,No,no preference,Yes -LEC002,22,Science: Biology/Life,,53703,pepperoni,Yes,Yes,night owl,Yes -LEC003,,Computer Science,Possibly Data Science (Definitely a Certificate),53706,Other,No,No,night owl,Yes -LEC002,19,Engineering: Mechanical,,53562,pepperoni,Yes,Yes,night owl,Yes -LEC002,19,Other,Data Science,53715,green pepper,Yes,Yes,no preference,Yes -LEC003,18,Statistics,,53706,Other,No,No,night owl,Yes -LEC004,19,Engineering: Mechanical,,53715,sausage,Yes,No,night owl,Yes -LEC003,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC002,21,Business: Other,,53703,mushroom,No,No,no preference,Yes -LEC003,19,Business: Information Systems,,53711,pepperoni,Yes,No,night owl,Yes -LEC002,19,Business: Actuarial,,53706,sausage,No,No,night owl,Yes -LEC002,21,Data Science,,53703,sausage,Yes,Yes,night owl,Yes -LEC001,23,Data Science,,53705,mushroom,Yes,No,night owl,Yes -LEC002,20,Computer Science,Data Science,53726,pineapple,Yes,Yes,night owl,Maybe -LEC003,18,Engineering: Industrial,,53706,pepperoni,Yes,No,night owl,Yes -LEC002,27,Data Science,,53705,basil/spinach,Yes,No,night owl,Yes -LEC002,18,Computer Science,Data Science,53706,mushroom,Yes,No,early bird,Yes -LEC001,22,Data Science,,53706,sausage,Yes,No,night owl,Yes -LEC002,20,Computer Science,,53715,pepperoni,No,Yes,night owl,Yes -LEC002,21,Data Science,,53703,macaroni/pasta,No,No,night owl,No -LEC002,20,Computer Science,,,mushroom,Yes,No,early bird,Maybe -LEC001,19,Computer Science,prolly data science,92376,pepperoni,Yes,No,night owl,Yes -LEC002,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,night owl,Maybe -LEC002,19,Engineering: Mechanical,,,none (just cheese),Yes,No,night owl,Yes -LEC002,19,Data Science,,53717,none (just cheese),Yes,No,night owl,Yes -LEC002,22,Science: Other,,53715,green pepper,Yes,Yes,early bird,Yes -LEC002,19,Engineering: Biomedical,,53706,sausage,Yes,No,early bird,No -LEC002,20,Business: Finance,,53703,pepperoni,Yes,No,early bird,No -LEC002,18,Business: Actuarial,,53706,pepperoni,Yes,No,early bird,No -LEC002,19,Engineering: Mechanical,,53706,Other,Yes,No,night owl,Yes -LEC002,20,Data Science,economics,internation student,mushroom,Yes,Yes,early bird,Maybe -LEC003,19,Engineering: Mechanical,,,Other,No,No,night owl,Yes -LEC002,19,Engineering: Industrial,,53703,sausage,No,Yes,night owl,Yes -LEC002,19,Engineering: Mechanical,,53701,pepperoni,Yes,Yes,no preference,Yes -LEC002,22,Computer Science,,53703,sausage,Yes,No,night owl,Yes -LEC001,19,Engineering: Industrial,,53715,pepperoni,Yes,No,no preference,Maybe -LEC002,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC002,23,Mathematics/AMEP,,53719,sausage,No,Yes,early bird,Yes -LEC002,18,Engineering: Industrial,,53706,pineapple,No,Yes,no preference,Maybe -LEC002,20,Other,Communication Arts,53711,sausage,Yes,Yes,no preference,Maybe -LEC002,21,Business: Information Systems,Finance ,53703,pepperoni,Yes,Yes,night owl,Maybe -LEC002,21,Science: Physics,Astrophysics,,macaroni/pasta,Yes,No,no preference,Maybe -LEC002,21,Science: Biology/Life,,53703,green pepper,Yes,No,early bird,Maybe -LEC003,21,Engineering: Other,,53706,none (just cheese),Yes,No,early bird,Maybe -LEC002,19,Data Science,Economics,53715,pepperoni,Yes,No,night owl,Yes -LEC001,19,Data Science,,53706,none (just cheese),No,Yes,night owl,Yes -LEC001,20,Statistics,"economics, social science",53715,pepperoni,No,No,no preference,Yes -LEC004,19,Business: Other,"Information systems, Data science",53706,sausage,Yes,Yes,night owl,Yes -LEC004,18,Computer Science,,53706,basil/spinach,Yes,No,no preference,Yes -LEC003,18,Computer Science,,53703,pepperoni,Yes,No,night owl,Yes -LEC003,,Mathematics/AMEP,,,mushroom,No,Yes,night owl,Yes -LEC004,19,Data Science,,53706,mushroom,Yes,No,night owl,Yes -LEC001,19,Science: Chemistry,Data Science,53706,sausage,Yes,No,night owl,No -LEC002,19,Mathematics/AMEP,,53703,Other,No,No,night owl,Yes -LEC003,18,Other,,53703,pineapple,No,No,early bird,No -LEC004,19,Engineering: Mechanical,,53703,pepperoni,Yes,No,early bird,Yes -LEC003,19,Statistics,thinking about a data science certificate or switching major to data science,53706,pepperoni,Yes,No,night owl,Yes -LEC001,19,Other,,53706,pepperoni,Yes,Yes,night owl,Maybe -LEC003,18,Statistics,data science,53706,pineapple,No,No,night owl,Maybe -LEC003,21,Computer Science,,53705,mushroom,Yes,No,night owl,Maybe -LEC002,21,Other,Data Science,53705,sausage,Yes,No,night owl,Yes -LEC003,20,Science: Biology/Life,,53703,pineapple,No,No,early bird,Maybe -LEC003,18,Other,,53715,pepperoni,Yes,No,early bird,No -LEC004,18,Engineering: Biomedical,,53706,pepperoni,Yes,Yes,early bird,Yes -LEC001,21,Computer Science,,53715,macaroni/pasta,Yes,No,night owl,Yes -LEC003,21,Science: Other,Data Science,53711,mushroom,Yes,Yes,night owl,Yes -LEC004,19,Engineering: Mechanical,,,sausage,No,No,early bird,No -LEC002,20,Engineering: Industrial,,53715,mushroom,No,No,night owl,Yes -LEC002,19,Engineering: Mechanical,,53706,pepperoni,Yes,No,no preference,No -LEC002,22,Science: Physics,,53703,sausage,Yes,No,night owl,Yes -LEC004,19,Engineering: Other,,53706,sausage,Yes,Yes,no preference,Maybe -LEC001,19,Engineering: Biomedical,,53711,macaroni/pasta,Yes,No,night owl,Yes -LEC001,23,Data Science,,53703,mushroom,Yes,Yes,night owl,Maybe -LEC001,20,Engineering: Industrial,,53703,pepperoni,Yes,No,night owl,Yes -LEC003,18,Science: Other,,53706,pineapple,Yes,Yes,night owl,Yes -LEC003,25,Computer Science,,53713,sausage,Yes,No,night owl,Yes -LEC001,31,Data Science,,53575,sausage,Yes,Yes,early bird,Maybe -LEC001,19,Data Science,,53715,pepperoni,Yes,Yes,night owl,Yes -LEC002,21,Computer Science,,53703,pepperoni,Yes,No,night owl,Yes -LEC003,20,Business: Actuarial,Risk Management and Insurance,53715,pepperoni,Yes,No,night owl,No -LEC004,19,Data Science,,53715,pepperoni,Yes,Yes,night owl,Yes -LEC001,19,Computer Science,,53706,mushroom,Yes,No,early bird,Maybe -LEC001,19,Mathematics/AMEP,,,pepperoni,Yes,No,night owl,Maybe -LEC001,19,Engineering: Mechanical,,53705,sausage,Yes,No,night owl,Yes -LEC004,19,Engineering: Mechanical,,53706,pineapple,Yes,No,night owl,Yes -LEC002,19,Science: Physics,,53706,Other,Yes,No,no preference,Yes -LEC001,21,Computer Science,Data science,53703,basil/spinach,No,Yes,night owl,No -LEC003,19,Mathematics/AMEP,data science,53706,sausage,Yes,No,night owl,Yes -LEC002,18,Science: Biology/Life,data science certificate,53706,pineapple,Yes,Yes,night owl,Yes -LEC004,18,Statistics,,53706,sausage,No,Yes,night owl,Yes -LEC003,21,Engineering: Industrial,,53562,pepperoni,Yes,No,night owl,Maybe -LEC001,20,Engineering: Mechanical,,53715,green pepper,Yes,No,early bird,Yes -LEC003,19,Engineering: Mechanical,,,pineapple,No,No,early bird,No -LEC003,20,Statistics,,53703,mushroom,Yes,Yes,no preference,No -LEC002,18,Engineering: Mechanical,"Industrial, Buisness",53701,pepperoni,No,No,night owl,Maybe -LEC001,18,Other,Legal Studies,53706,mushroom,No,No,night owl,Yes -LEC001,20,Data Science,,53703,none (just cheese),Yes,Yes,night owl,Yes -LEC001,21,Other,,53703,Other,Yes,Yes,no preference,Maybe -LEC001,22,Engineering: Biomedical,pre-med,53715,none (just cheese),Yes,Yes,no preference,Yes -LEC003,20,Other,"Philosophy, Data Science Certificate, Pre-Med",53703,basil/spinach,No,Yes,early bird,Yes -LEC001,21,Business: Finance,Economics,53703,basil/spinach,Yes,No,night owl,Yes -LEC003,19,Statistics,,53705,none (just cheese),Yes,Yes,no preference,Yes -LEC001,18,Engineering: Industrial,,53703,sausage,Yes,Yes,night owl,Yes -LEC003,21,Science: Biology/Life,My majors are Environmental Science and Spanish,53703,macaroni/pasta,Yes,No,night owl,Maybe -LEC001,18,Other,,,pepperoni,Yes,No,no preference,Yes -LEC004,23,Science: Physics,Astronomy,53703,pepperoni,Yes,Yes,night owl,Yes -LEC002,21,Computer Science,,53711,sausage,Yes,No,night owl,Maybe -LEC002,18,Engineering: Mechanical,,53706,sausage,Yes,Yes,early bird,Yes -LEC003,19,Engineering: Other,Environmental Science,53706,pepperoni,Yes,No,night owl,Yes -LEC003,19,Science: Other,Life science communications,53706,Other,Yes,No,night owl,Maybe -LEC004,21,Engineering: Mechanical,,53703,sausage,Yes,Yes,no preference,No -LEC001,20,Computer Science,,53703,pineapple,Yes,No,night owl,Yes -LEC001,20,Other,,53703,macaroni/pasta,Yes,Yes,night owl,Yes -LEC001,22,Other,"psychology, legal studies, certificate in criminal justice ",53711,sausage,Yes,No,night owl,Maybe -LEC002,21,Data Science,,53711,none (just cheese),Yes,No,night owl,Yes -LEC003,21,Other,,53703,mushroom,Yes,No,early bird,Yes -LEC002,20,Engineering: Industrial,,53703,pineapple,Yes,Yes,early bird,Yes -LEC001,19,Computer Science,data science,53706,pineapple,No,No,night owl,No -LEC003,19,Statistics,Data Science,53703,pineapple,No,No,night owl,Maybe -LEC001,20,Computer Science,,53726,none (just cheese),Yes,No,night owl,Yes -LEC002,,Computer Science,,,pepperoni,Yes,No,night owl,Maybe -LEC001,18,Computer Science,,53706,pineapple,No,No,no preference,Maybe -LEC001,19,Computer Science,data science,53706,pepperoni,Yes,Yes,night owl,Yes -LEC003,19,Other,Undecided in STEM,53706,pepperoni,No,No,night owl,No -LEC001,18,Computer Science,data science,53590,Other,No,No,night owl,Yes -LEC004,18,Other,,53706,Other,Yes,No,night owl,Maybe -LEC003,19,Data Science,,53706,basil/spinach,Yes,No,no preference,Maybe -LEC001,19,Business: Finance,,53706,pepperoni,Yes,No,night owl,Maybe -LEC001,19,Engineering: Industrial,,53704,basil/spinach,No,No,no preference,Yes -LEC004,18,Engineering: Other,,53706,pepperoni,Yes,No,night owl,Maybe -LEC002,18,Computer Science,,,macaroni/pasta,Yes,Yes,night owl,Yes -LEC003,20,Engineering: Biomedical,,53715,none (just cheese),Yes,Yes,no preference,Maybe -LEC001,18,Other,,52816,none (just cheese),Yes,No,night owl,Yes -LEC002,18,Engineering: Mechanical,Computes Science Certificate Potentially,53706,sausage,Yes,Yes,night owl,Yes -LEC002,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,no preference,No -LEC003,20,Business: Finance,Business: Risk Management ,53703,sausage,Yes,Yes,night owl,Yes -LEC001,19,Science: Chemistry,,53706,pineapple,Yes,No,night owl,Yes -LEC001,20,Engineering: Mechanical,,59301,pepperoni,Yes,Yes,no preference,Maybe -LEC001,22,Mathematics/AMEP,Economics ,53715,basil/spinach,Yes,Yes,early bird,No -LEC001,22,Other,,53703,green pepper,Yes,Yes,night owl,Yes -LEC001,19,Engineering: Other,,53715,none (just cheese),Yes,Yes,night owl,No -LEC002,18,Engineering: Mechanical,,53706,sausage,Yes,Yes,night owl,Yes -LEC001,23,Engineering: Other,,53711,green pepper,Yes,Yes,no preference,Maybe -LEC001,18,Science: Chemistry,,53706,sausage,Yes,Yes,night owl,No -LEC001,23,Engineering: Mechanical,,53715,pepperoni,Yes,Yes,night owl,Maybe -LEC002,19,Data Science,Economics,53706,macaroni/pasta,No,No,early bird,Yes -LEC001,20,Engineering: Industrial,"Science: Other, Economics",53703,sausage,Yes,Yes,early bird,No -LEC003,21,Data Science,"Economics, Social Science",53703,sausage,Yes,Yes,no preference,Maybe -LEC002,18,Data Science,,10306,none (just cheese),Yes,No,night owl,Maybe -LEC002,20,Mathematics/AMEP,Environmental Sciences,53715,pepperoni,No,No,night owl,Maybe -LEC002,18,Statistics,,53706,pepperoni,Yes,No,night owl,Maybe -LEC003,21,Engineering: Mechanical,,53715,pepperoni,Yes,Yes,night owl,Yes -LEC002,20,Engineering: Biomedical,,53703,pepperoni,Yes,No,night owl,Yes -LEC002,19,Data Science,,53703,pineapple,Yes,No,no preference,Yes -LEC001,21,Engineering: Other,,53715,mushroom,No,No,early bird,Maybe -LEC003,18,Data Science,possibly Statistics / Math,53706,mushroom,Yes,No,night owl,Yes -LEC002,,Business: Other,,,pepperoni,Yes,No,early bird,No -LEC002,19,Other,,53706,pepperoni,Yes,No,night owl,Yes -LEC001,19,Engineering: Other,,53706,pineapple,Yes,No,night owl,Maybe -LEC003,19,Computer Science,data science I havent decided on a major yet but it might be either one of these,53726,none (just cheese),No,No,night owl,Maybe -LEC003,20,Business: Finance,,53703,Other,Yes,No,night owl,Yes -LEC001,21,Science: Other,,53703,sausage,No,No,night owl,Yes -LEC001,20,Other,,53703,pepperoni,No,No,night owl,Yes -LEC004,20,Engineering: Other,,53703,none (just cheese),Yes,No,night owl,Yes -LEC001,21,Business: Information Systems,,53703,Other,Yes,Yes,no preference,No -LEC003,21,Mathematics/AMEP,,,mushroom,No,No,night owl,Yes -LEC001,18,Other,,53703,mushroom,Yes,No,night owl,Yes -LEC003,19,Business: Actuarial,,53175,sausage,Yes,Yes,early bird,Yes -LEC003,20,Engineering: Mechanical,Naval Architecture & Marnie Engineering (self-tutored),53711,green pepper,Yes,No,night owl,Maybe -LEC002,20,Business: Other,,53703,pineapple,Yes,No,night owl,Maybe -LEC003,20,Data Science,"computer science, stats ",53711,pineapple,Yes,No,early bird,Yes -LEC004,19,Statistics,,53706,pepperoni,Yes,No,night owl,Yes -LEC003,18,Engineering: Industrial,Data science ,53715,pepperoni,No,Yes,early bird,Maybe -LEC004,20,Other,"Economics, Data Science",53715,mushroom,Yes,No,no preference,Maybe -LEC001,19,Engineering: Mechanical,,53706,sausage,Yes,Yes,night owl,Yes -LEC002,21,Engineering: Mechanical,Spanish,53719,none (just cheese),Yes,Yes,night owl,Maybe -LEC001,24,Engineering: Industrial,Business,53726,mushroom,Yes,No,night owl,Maybe -LEC002,20,Other,NA,53703,basil/spinach,Yes,Yes,night owl,Yes -LEC004,18,Engineering: Mechanical,,53706,sausage,Yes,Yes,early bird,Yes -LEC001,19,Other,"Data Science Certificate, Economics",53703,sausage,No,Yes,night owl,Yes -LEC001,18,Engineering: Mechanical,,53706,pepperoni,No,No,night owl,Yes -LEC003,18,Engineering: Mechanical,,53706,pepperoni,Yes,Yes,night owl,Yes -LEC004,19,Engineering: Biomedical,,53706,none (just cheese),Yes,No,no preference,Yes -LEC001,20,Computer Science,,53715,sausage,Yes,No,night owl,Yes -LEC001,17,Engineering: Mechanical,,53706,pineapple,Yes,No,night owl,Yes -LEC002,20,Data Science,,53703,pepperoni,Yes,Yes,night owl,Yes -LEC003,18,Engineering: Mechanical,,53715,pineapple,No,No,night owl,Maybe -LEC003,19,Engineering: Biomedical,,53703,none (just cheese),Yes,Yes,night owl,Yes -LEC003,20,Other,Data Science,53715,mushroom,Yes,Yes,early bird,Maybe -LEC003,19,Mathematics/AMEP,,53705,pineapple,No,No,night owl,Yes -LEC002,19,Engineering: Mechanical,chemical engineering,53711,green pepper,Yes,No,night owl,Maybe -LEC003,21,Computer Science,Data Science,53715,mushroom,No,No,night owl,Maybe -LEC003,19,Data Science,,53590,pepperoni,No,No,no preference,Yes -LEC001,20,Computer Science,,,pepperoni,Yes,No,early bird,Yes -LEC001,20,Data Science,"Biology, Bioinformatics",53703,sausage,Yes,No,no preference,Yes -LEC002,21,Engineering: Mechanical,,53705,none (just cheese),Yes,No,no preference,Maybe -LEC001,19,Computer Science,Data Science,53706,Other,No,Yes,night owl,No -LEC001,20,Business: Finance,Data Science,53715,sausage,Yes,Yes,night owl,Yes -LEC001,19,Data Science,Computer science,53706,pineapple,No,Yes,no preference,Yes -LEC002,23,Science: Other,Computer Science,53711,pineapple,Yes,Yes,early bird,No -LEC003,18,Engineering: Mechanical,,53706,sausage,No,No,night owl,No -LEC001,19,Computer Science,Data Science,53703,Other,No,No,no preference,Maybe -LEC001,19,Science: Other,,53706,macaroni/pasta,Yes,No,night owl,Yes -LEC003,19,Other,I do not have a secondary major but my major is International Studies. ,53076,pepperoni,Yes,Yes,early bird,Yes -LEC001,21,Science: Biology/Life,,53715,pepperoni,Yes,No,night owl,Yes -LEC001,20,Engineering: Mechanical,,53726,pepperoni,Yes,No,night owl,Yes -LEC002,20,Engineering: Industrial,,53715,pepperoni,Yes,No,no preference,Yes -LEC003,20,Science: Biology/Life,Life Science Communication,53703,pepperoni,Yes,No,early bird,Maybe -LEC002,19,Science: Biology/Life,Data Science,,pepperoni,No,No,no preference,Maybe -LEC002,22,Computer Science,,53703,sausage,Yes,No,night owl,Yes -LEC001,20,Business: Information Systems,,53706,mushroom,Yes,No,night owl,Yes -LEC001,19,Business: Other,,53706,pepperoni,Yes,No,early bird,Yes -LEC001,21,Other,"Economics/Philosophy, Data Science Certificate",53703,pepperoni,Yes,No,no preference,Yes -LEC003,19,Computer Science,Data science,53706,pineapple,Yes,Yes,night owl,Yes +Lecture,Age,Major,Zip Code,Latitude,Longitude,Pizza topping,Pet preference,Runner,Sleep habit,Procrastinator +LEC001,22,Engineering: Biomedical,53703,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC006,,Undecided,53706,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC004,18,Engineering: Industrial,53715,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC005,,Undecided,53706,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC002,,Undecided,53706,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC004,18,Engineering: Other|Engineering: Computer,53706,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC003,,Undecided,53706,43.073051,-89.40123,none (just cheese),neither,No,no preference,Maybe +LEC003,18,Data Science,53715,43.073051,-89.40123,pineapple,cat,Yes,no preference,Maybe +LEC006,18,Data Science,53706,35.4,119.11,none (just cheese),dog,No,night owl,Yes +LEC006,18,Mathematics/AMEP,53706,44,-93,pepperoni,dog,No,night owl,Yes +LEC002,21,Engineering: Other,53703,24.713552,46.675297,none (just cheese),cat,Yes,night owl,Maybe +LEC003,19,Data Science,53705,24.6806,46.57936,pineapple,cat,No,early bird,No +LEC004,24,Economics,53703,43,-89,pineapple,cat,Yes,early bird,Yes +LEC003,18,Data Science,53706,36.102371,-115.174553,none (just cheese),dog,No,night owl,Yes +LEC006,22,Psychology,53703,31.78,119.95,mushroom,cat,No,night owl,Yes +LEC005,20,Data Science,53705,37.8,112.5,pepperoni,cat,Yes,night owl,Yes +LEC004,24,Science: Biology/Life,53703,46.872131,-113.994019,pepperoni,dog,Yes,early bird,Yes +LEC004,17,Engineering: Mechanical,53706,46.6242,8.0414,pineapple,dog,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53726,43.073051,-89.40123,none (just cheese),dog,Yes,early bird,No +LEC002,19,Engineering: Mechanical,57303,41.878113,-87.629799,pineapple,dog,No,night owl,Yes +LEC001,,Mathematics/AMEP,53706,31.230391,121.473701,basil/spinach,dog,No,no preference,Maybe +LEC002,19,Mathematics/AMEP,53558,40.712776,-74.005974,sausage,dog,Yes,night owl,Yes +LEC001,20,Economics (Mathematical Emphasis),53703,48.86,2.3522,pepperoni,dog,No,early bird,Yes +LEC001,19,Engineering: Mechanical,53703,24.7,46.7,mushroom,dog,Yes,early bird,Maybe +LEC005,18,Computer Science,53703,37.338207,-121.88633,green pepper,dog,Yes,night owl,Yes +LEC003,19,Engineering: Mechanical,53558,43.073051,-89.40123,pepperoni,dog,No,night owl,Yes +LEC005,20,Engineering: Mechanical,53715,38.9072,-77.0369,Other,cat,No,night owl,Yes +LEC003,20,Data Science,53703,43.073051,-89.40123,pepperoni,dog,No,night owl,Yes +LEC002,21,Science: Other|Political Science,53703,31.768318,35.213711,pepperoni,dog,No,no preference,Maybe +LEC003,19,Mathematics/AMEP,53715,19.075983,72.877655,basil/spinach,cat,No,night owl,Maybe +LEC001,23,Computer Science,53711,43.073929,-89.385239,sausage,dog,No,night owl,Yes +LEC006,21,Business: Other,53715,25.761681,-80.191788,pepperoni,dog,No,night owl,Yes +LEC003,19,Business: Other|Real Estate,53715,117,33,pepperoni,dog,Yes,night owl,No +LEC004,19,Computer Science,53726,47.037872,-122.900696,tater tots,dog,No,night owl,Yes +LEC004,24,Economics,53703,23.12911,113.264381,pepperoni,cat,Yes,early bird,Maybe +LEC005,19,Data Science,53703,64.49796,165.40998,sausage,dog,No,night owl,Yes +LEC003,19,Data Science,53705,25,47,mushroom,cat,No,early bird,Maybe +LEC005,20,Engineering: Other|Engineering Physics: Scientific Computing,53715,43.073051,-89.4,none (just cheese),dog,No,night owl,Yes +LEC005,20,Computer Science,53703,48.856613,2.352222,pepperoni,dog,No,night owl,Yes +LEC002,19,Business: Finance,53726,43.04156,87.91006,pepperoni,dog,No,night owl,Yes +LEC002,21,Data Science,53713,29.868336,121.543991,mushroom,dog,No,night owl,No +LEC004,19,Computer Science,53715,40.712776,-74.005974,pepperoni,dog,No,night owl,Maybe +LEC003,18,Computer Science,53706,5.93876,80.48433,Other,dog,No,night owl,Maybe +LEC005,19,Engineering: Mechanical,53704,38.7,-77,pepperoni,cat,Yes,no preference,No +LEC004,18,Engineering: Mechanical,53726,41.878113,-87.629799,pepperoni,dog,No,night owl,Maybe +LEC005,19,Engineering: Other,53703,36.169941,-115.139832,pepperoni,dog,No,night owl,Maybe +LEC005,19,Engineering: Mechanical,53703,43.078104,-89.431698,pepperoni,dog,Yes,night owl,Yes +LEC006,18,Engineering: Biomedical,53051,33.6846,117.8265,pepperoni,dog,Yes,night owl,Yes +LEC001,22,Engineering: Mechanical,53719,43.073051,-89.40123,none (just cheese),cat,Yes,night owl,Yes +LEC001,18,Computer Science,53706,26.2992,87.2625,mushroom,dog,Yes,night owl,No +LEC001,24,Business: Information Systems,53703,43.073051,-89.40123,macaroni/pasta,cat,No,night owl,No +LEC006,19,Engineering: Mechanical,53703,43.04049,-87.91732,Other,dog,No,night owl,Yes +LEC001,,Computer Science,53715,34.052235,-118.243683,green pepper,dog,No,night owl,Yes +LEC002,20,Statistics,53703,40.7128,74.006,Other,dog,No,night owl,Maybe +LEC005,23,Computer Science,53703,37.5,126.97,pepperoni,dog,No,night owl,No +LEC002,21,Statistics,53703,52.370216,4.895168,pepperoni,dog,Yes,early bird,Maybe +LEC002,18,Undecided,53706,38.56247,-121.70411,pepperoni,dog,Yes,night owl,Yes +LEC006,18,Statistics,53706,40.712776,40.712776,pepperoni,dog,No,night owl,Yes +LEC003,21,Economics,53715,43.073051,-89.40123,none (just cheese),dog,No,night owl,Yes +LEC003,19,Engineering: Mechanical,53715,45,-93,sausage,dog,No,night owl,No +LEC005,21,Business: Finance,53717,40.6461,-111.498,sausage,dog,No,night owl,Yes +LEC001,26,Engineering: Mechanical,53703,41.902782,12.496365,pepperoni,dog,No,night owl,Yes +LEC001,25,Economics,53703,40.712776,-74.005974,pepperoni,dog,No,night owl,Yes +LEC003,18,Mathematics/AMEP,53706,31.230391,121.473701,mushroom,dog,Yes,early bird,No +LEC001,19,Computer Science,53706,48.855709,2.29889,pepperoni,cat,Yes,night owl,Yes +LEC005,17,Science: Biology/Life,53706,-18.766947,46.869106,basil/spinach,dog,Yes,early bird,Maybe +LEC003,19,Business: Information Systems,53711,38.893452,-77.014709,pepperoni,dog,No,early bird,Yes +LEC001,21,Computer Science,53715,16.306652,80.436539,Other,dog,No,night owl,Yes +LEC006,19,Data Science,53703,35.689487,139.691711,sausage,neither,Yes,no preference,Maybe +LEC004,18,Engineering: Industrial,53706,17.385044,78.486671,mushroom,dog,No,early bird,Yes +LEC004,19,Computer Science,53715,37.774929,-122.419418,pepperoni,dog,No,night owl,Maybe +LEC004,19,Data Science,53703,26.2644,20.3052,pepperoni,dog,No,night owl,Yes +LEC005,18,Data Science,53706,40.712776,-74.005974,pepperoni,dog,Yes,no preference,Yes +LEC002,18,Data Science,53706,36,117,Other,dog,No,early bird,Maybe +LEC005,19,Data Science,50703,42.360081,-71.058884,sausage,cat,No,night owl,No +LEC006,19,Computer Science,53711,36.569666,112.218744,pineapple,neither,Yes,early bird,Maybe +LEC005,18,Computer Science,53706,37.54443,-121.95269,pepperoni,dog,No,night owl,Maybe +LEC003,20,Mathematics/AMEP,53715,32.0853,34.781769,mushroom,dog,No,no preference,Yes +LEC003,19,Data Science,53715,42.701847,-84.48217,tater tots,dog,No,night owl,Yes +LEC003,18,Mathematics/AMEP,53706,40.179188,44.499104,Other,dog,Yes,no preference,Yes +LEC002,,Computer Science,53711,2.81375,101.504272,sausage,dog,Yes,no preference,Maybe +LEC001,18,Engineering: Industrial,53715,30.733315,76.779419,green pepper,cat,No,no preference,Yes +LEC003,21,Data Science,53590,7.9519,98.3381,Other,dog,Yes,early bird,Yes +LEC004,19,Data Science,53715,35.69,139.69,mushroom,dog,No,no preference,Maybe +LEC002,19,Data Science,53704,26.473308,50.048218,Other,cat,Yes,night owl,Yes +LEC002,22,Economics,53703,34.052235,-118.243683,pineapple,dog,No,night owl,Yes +LEC006,18,Data Science,53706,19.075983,72.877655,mushroom,dog,Yes,night owl,Yes +LEC003,,Business: Actuarial,53705,39.6336,118.16,basil/spinach,dog,Yes,early bird,Yes +LEC003,18,Data Science,53706,52.370216,4.895168,mushroom,cat,Yes,no preference,No +LEC003,18,Engineering: Mechanical,53706,52.368944,4.891663,pepperoni,cat,No,night owl,No +LEC002,18,Science: Physics,53703,32,118,sausage,neither,No,night owl,No +LEC005,18,Data Science,53706,17.384716,78.409424,mushroom,dog,Yes,night owl,Maybe +LEC003,19,Data Science,53715,3.1569,101.7123,mushroom,cat,No,early bird,No +LEC005,18,Computer Science,53706,43.769562,11.255814,Other,neither,No,night owl,Yes +LEC006,18,Business: Actuarial,53706,48.856613,2.352222,mushroom,cat,No,no preference,Yes +LEC004,20,Business: Actuarial,53711,40.7128,74.006,pepperoni,dog,Yes,early bird,No +LEC005,20,Science: Biology/Life,53703,44.67082,-93.24432,mushroom,dog,No,no preference,Maybe +LEC004,18,Mathematics/AMEP,53706,46.786671,-92.100487,pepperoni,cat,No,early bird,Yes +LEC005,20,Economics,53703,48.856613,2.352222,pepperoni,neither,No,night owl,Maybe +LEC006,18,Business: Finance,53706,40.409264,49.867092,Other,neither,No,early bird,No +LEC004,21,Computer Science,53715,27.993828,120.699364,green pepper,dog,Yes,no preference,No +LEC002,,Computer Science,53706,43.073051,-89.40123,Other,neither,Yes,no preference,Maybe +LEC002,20,Engineering: Mechanical,53706,35.6762,139.6503,sausage,cat,Yes,night owl,Yes +LEC001,20,Economics (Mathematical Emphasis),53703,43.073929,-89.385239,macaroni/pasta,cat,No,night owl,No +LEC002,21,Business: Information Systems,53713,43.03638,-89.40292,pineapple,neither,Yes,night owl,Yes +LEC004,18,Data Science,53706,45.31625,-92.59181,pepperoni,dog,No,night owl,Yes +LEC001,21,Business: Finance,53711,43.073929,-89.385239,pepperoni,dog,No,no preference,Maybe +LEC005,19,Engineering: Mechanical,53715,35.689487,139.691711,pepperoni,dog,No,night owl,Yes +LEC003,18,Computer Science,53706,51.500153,-0.1262362,pepperoni,dog,No,night owl,Yes +LEC002,22,Science: Biology/Life,53711,43.073051,-89.40123,mushroom,cat,No,no preference,No +LEC004,18,Data Science,53706,42.360081,-71.058884,green pepper,dog,No,night owl,Yes +LEC005,19,Engineering: Mechanical,53703,32.8328,117.2713,sausage,neither,Yes,night owl,Yes +LEC003,20,Engineering: Mechanical,53715,44.834,-87.376,none (just cheese),dog,Yes,night owl,No +LEC006,21,Economics,53703,41.902782,12.496365,none (just cheese),dog,No,no preference,Yes +LEC003,25,Data Science,53703,34.693737,135.502167,pineapple,dog,No,early bird,Maybe +LEC003,17,Computer Science,53703,19.075983,72.877655,Other,neither,Yes,no preference,No +LEC002,19,Psychology,53715,30.5928,114.3052,sausage,cat,No,night owl,Yes +LEC001,19,Computer Science,53703,51.507351,-0.127758,sausage,cat,Yes,no preference,Yes +LEC006,17,Engineering: Industrial,53706,55.953251,-3.188267,Other,dog,No,night owl,Yes +LEC005,,Computer Science,53703,43.073051,-89.40123,pineapple,dog,Yes,night owl,No +LEC002,21,Engineering: Mechanical,53705,37.566536,126.977966,mushroom,cat,Yes,no preference,Maybe +LEC002,18,Undecided,53715,48.775845,9.182932,Other,dog,No,night owl,Yes +LEC004,19,Data Science,53703,43,-89,sausage,cat,No,early bird,Maybe +LEC001,21,Science: Biology/Life,53703,36,117,macaroni/pasta,dog,No,night owl,Maybe +LEC002,19,Business: Information Systems,53703,42.360081,-71.058884,pepperoni,dog,No,no preference,Yes +LEC005,19,Computer Science,53706,-8.340539,115.091949,pineapple,dog,Yes,night owl,Maybe +LEC003,20,Business: Information Systems,53726,43.073051,-89.40123,sausage,dog,Yes,night owl,No +LEC003,,Science: Other,53715,39.904202,116.407394,mushroom,cat,No,night owl,Maybe +LEC004,20,Engineering: Biomedical,53715,43.0707,12.6196,tater tots,dog,No,night owl,Maybe +LEC004,19,Engineering: Biomedical,53715,41.878113,-87.629799,mushroom,dog,Yes,night owl,Yes +LEC002,21,Business: Other|Accounting,53703,41.8781,87.6298,pepperoni,cat,No,night owl,No +LEC002,17,Undecided,53706,33.742185,-84.386124,Other,dog,No,no preference,Yes +LEC006,18,Data Science,53558,40.73061,-73.935242,pepperoni,dog,Yes,night owl,No +LEC003,25,Data Science,53705,43.073051,-89.385239,sausage,cat,No,night owl,Maybe +LEC002,18,Data Science,53706,37.34163,-122.05411,sausage,dog,No,night owl,Yes +LEC006,18,Science: Biology/Life,53706,19.21833,72.978088,green pepper,neither,No,no preference,Maybe +LEC002,,Business: Other|business analytics,53703,31.230391,121.473701,none (just cheese),cat,Yes,night owl,Maybe +LEC003,,Data Science,53706,35.719312,139.784546,none (just cheese),neither,Yes,night owl,Yes +LEC002,19,Engineering: Mechanical,53726,47.141041,9.52145,mushroom,dog,No,night owl,Yes +LEC002,,Computer Science,53715,41.8781,87.6298,pepperoni,dog,No,no preference,Maybe +LEC002,26,Science: Other|animal sciences,53705,25.204849,55.270782,pepperoni,dog,No,no preference,Maybe +LEC003,21,Mathematics,53704,61.218056,-149.900284,green pepper,cat,Yes,early bird,Maybe +LEC003,22,Engineering: Other,53703,49.28273,-123.120735,macaroni/pasta,cat,No,early bird,Maybe +LEC001,18,Engineering: Other,53706,41.902782,12.496365,pepperoni,dog,No,night owl,Yes +LEC003,20,Engineering: Mechanical,53726,39.81059,-74.71795,basil/spinach,dog,No,early bird,Yes +LEC003,21,Health Promotion and Health Equity,53711,37.2982,113.0263,pepperoni,dog,No,early bird,No +LEC003,20,Engineering: Mechanical,53703,38.722252,-9.139337,mushroom,dog,No,night owl,Yes +LEC003,19,Engineering: Mechanical,53714,43,-89.4,none (just cheese),dog,No,night owl,Yes +LEC002,19,Engineering: Industrial,53703,41.878,-87.63,pepperoni,dog,Yes,night owl,Yes +LEC003,18,Computer Science,53706,43.073051,-89.40123,mushroom,neither,No,night owl,Yes +LEC001,18,Engineering: Industrial,53706,19.655041,-101.169891,pepperoni,dog,Yes,no preference,Maybe +LEC005,20,Engineering: Mechanical,53703,26.147,-81.795,pepperoni,dog,Yes,early bird,Yes +LEC006,18,Business: Other,53706,51.507,-0.128,sausage,dog,No,no preference,No +LEC005,19,Business: Other,53706,43,-89,pepperoni,dog,Yes,no preference,Yes +LEC004,19,Engineering: Mechanical,53705,34.869709,-111.760902,pepperoni,cat,No,no preference,Maybe +LEC005,21,Business: Finance,53703,3.15443,101.715103,pepperoni,cat,No,night owl,Yes +LEC005,18,Engineering: Mechanical,53706,44.655991,-93.242752,none (just cheese),dog,Yes,night owl,Yes +LEC003,18,Art,53706,36.25,138.25,macaroni/pasta,dog,No,night owl,Yes +LEC005,19,Data Science,53715,41.94288,-87.68667,pepperoni,dog,Yes,night owl,Yes +LEC005,18,Data Science,53703,44.2795,73.9799,pepperoni,dog,Yes,night owl,No +LEC002,19,Mathematics/AMEP,53715,37.80718,23.734864,pineapple,cat,No,night owl,Yes +LEC004,18,Computer Science,53706,35.689487,139.691711,pepperoni,cat,No,night owl,Yes +LEC006,18,Engineering: Mechanical,53706,43.0826,-97.16051,pepperoni,dog,No,no preference,Yes +LEC006,18,Engineering: Other,53715,37.441883,-122.143021,mushroom,dog,Yes,night owl,Maybe +LEC006,18,Engineering: Mechanical,53706,44.883,-87.86291,pepperoni,dog,No,early bird,Yes +LEC004,19,Engineering: Mechanical,53706,40.73598,-74.37531,none (just cheese),dog,Yes,early bird,No +LEC001,20,Business: Actuarial,53703,42.28,-83.74,mushroom,dog,No,night owl,Yes +LEC003,17,Engineering: Mechanical,53706,37.98381,23.727539,pineapple,dog,Yes,night owl,No +LEC004,18,Computer Science,53706,40.27385,-74.75972,sausage,dog,Yes,night owl,Yes +LEC002,19,Economics,53703,90.1994,38.627,none (just cheese),dog,No,early bird,Yes +LEC002,21,"Mathematics, Data Science",53703,30.572815,104.066803,sausage,dog,No,night owl,Maybe +LEC002,,Computer Science,53717,36,139,mushroom,dog,Yes,early bird,Yes +LEC006,19,Science: Biology/Life,53715,45.289143,-87.021847,none (just cheese),cat,No,night owl,Maybe +LEC002,21,Mathematics/AMEP,53703,20.878332,-156.682495,pepperoni,cat,No,night owl,Yes +LEC003,22,Mathematics/AMEP,53715,44.481586,-88.005981,pepperoni,neither,No,night owl,Yes +LEC006,18,Data Science,53706,43.073051,-89.40123,pepperoni,dog,No,night owl,Yes +LEC005,18,Computer Science,53706,30.733315,76.779419,none (just cheese),dog,No,night owl,Yes +LEC005,20,Mathematics/AMEP,53703,38.837702,-238.449497,pepperoni,dog,No,night owl,Yes +LEC005,,Computer Science,53593,50.116322,-122.957359,sausage,dog,No,night owl,Yes +LEC005,18,Computer Science,53715,43.059023,-89.296875,pepperoni,cat,No,night owl,Maybe +LEC005,19,Engineering: Industrial,53703,22.2255,-159.4835,pepperoni,cat,Yes,night owl,Yes +LEC005,18,Engineering: Biomedical,53593,43.073051,-89.40123,green pepper,cat,No,night owl,Maybe +LEC005,20,Engineering: Mechanical,53715,41.283211,-70.099228,sausage,dog,No,no preference,Maybe +LEC005,18,Data Science,53715,25.26741,55.292679,basil/spinach,cat,Yes,early bird,Yes +LEC005,19,Business: Other,53726,43.038902,-87.906471,pepperoni,dog,No,night owl,Yes +LEC002,,Undecided,53703,30.5723,104.0665,sausage,dog,No,night owl,Yes +LEC006,18,Engineering: Mechanical,53706,30.2672,97.7431,pepperoni,dog,No,night owl,No +LEC006,20,Data Science,53703,36.731651,-119.785858,Other,dog,Yes,night owl,Yes +LEC005,18,Computer Science,53706,43.038902,-87.906471,pepperoni,dog,No,night owl,Yes +LEC004,,Business: Finance,53703,33.8688,151.2093,green pepper,dog,Yes,night owl,Yes +LEC005,18,Science: Other|Science: Genetics and Genomics,53715,43.073051,-89.40123,mushroom,dog,No,no preference,Yes +LEC003,19,Engineering: Mechanical,53715,44.90767,-93.183594,basil/spinach,dog,No,night owl,Maybe +LEC006,18,Business: Finance,53706,-33.448891,-70.669266,macaroni/pasta,dog,No,night owl,Yes +LEC006,17,Business: Finance,53706,43.296482,5.36978,pineapple,dog,No,night owl,Yes +LEC006,21,Mathematics/AMEP,53703,30.572815,104.066803,green pepper,dog,No,no preference,Maybe +LEC005,20,Engineering: Mechanical,53703,41.99884,-87.68828,Other,dog,No,no preference,No +LEC001,19,Business: Information Systems,53703,39.481655,-106.038353,macaroni/pasta,dog,Yes,night owl,Yes +LEC004,19,Engineering: Mechanical,53703,41.883228,-87.632401,pepperoni,dog,No,no preference,Maybe +LEC004,18,Engineering: Industrial,53706,41.878113,41.878113,pepperoni,dog,No,night owl,No +LEC004,19,Engineering: Mechanical,53703,28.228209,112.938812,none (just cheese),neither,Yes,early bird,Yes +LEC003,18,Data Science,89451,34.42083,-119.698189,green pepper,dog,No,early bird,No +LEC003,19,Computer Science,53703,41.3874,2.1686,pepperoni,cat,No,early bird,No +LEC005,20,Science: Biology/Life,53703,32.05196,118.77803,sausage,neither,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53706,50.075539,14.4378,none (just cheese),neither,No,night owl,Yes +LEC003,20,Statistics (actuarial route),53715,43.134315,-88.220062,sausage,dog,No,early bird,No +LEC004,19,Computer Science,53706,17.385044,78.486671,pepperoni,neither,Yes,night owl,Yes +LEC002,18,Engineering: Mechanical,53706,53707,-88.415382,Other,dog,No,night owl,Yes +LEC004,19,Computer Science,53706,45.440845,12.315515,sausage,dog,No,night owl,Yes +LEC004,18,Computer Science,53706,55.953251,-3.188267,Other,dog,No,night owl,Maybe +LEC004,18,Engineering: Mechanical,53706,33.8902,-118.39848,sausage,dog,Yes,night owl,Yes +LEC001,20,Business: Other|Business: Accounting,53703,31.230391,121.473701,pepperoni,cat,Yes,no preference,No +LEC004,18,Data Science,53706,39.512611,116.677063,pepperoni,dog,No,night owl,Maybe +LEC003,18,Undecided,53706,41.256538,95.934502,Other,dog,No,no preference,Yes +LEC003,18,Data Science,53706,19.075983,72.877655,pepperoni,dog,No,night owl,No +LEC003,22,Economics,53703,40.753685,-73.999161,green pepper,dog,No,night owl,Maybe +LEC003,18,Data Science,53706,51.507351,-0.127758,pepperoni,cat,No,night owl,Yes +LEC003,,Engineering: Mechanical,53706,42.44817,-71.224716,pepperoni,cat,Yes,night owl,Maybe +LEC003,17,Engineering: Other|Computer Engineering,53706,42.36,-71.059,basil/spinach,neither,No,early bird,Maybe +LEC003,21,Business: Actuarial,53706,32.715736,-117.161087,green pepper,dog,Yes,night owl,No +LEC003,,Engineering: Other|Computer engineering,53706,35.689487,139.691711,Other,cat,No,night owl,Yes +LEC003,18,Mathematics/AMEP,53715,41.385063,2.173404,pepperoni,cat,Yes,no preference,Maybe +LEC003,20,Computer Science,53705,30.274084,120.155067,mushroom,cat,No,night owl,Yes +LEC005,,Computer Science,53705,51.507351,-0.127758,basil/spinach,dog,No,night owl,Yes +LEC003,18,Computer Science,53706,45.45676,15.29662,sausage,dog,Yes,early bird,Yes +LEC003,18,Engineering: Industrial,53706,18.92421,-99.221565,green pepper,dog,Yes,night owl,Yes +LEC004,18,Engineering: Other|Material Science Engineering,53703,38.941631,-119.977219,pepperoni,dog,Yes,night owl,Yes +LEC002,21,Economics,53705,25.03841,121.5637,pepperoni,cat,No,night owl,Maybe +LEC005,,Civil engineering - hydropower engineering,53705,34,113,pineapple,neither,No,night owl,Maybe +LEC005,18,Computer Science,53706,40.7,-74.005,pepperoni,cat,No,early bird,No +LEC001,19,Engineering: Mechanical,53706,35.142441,-223.154297,green pepper,neither,Yes,night owl,Yes +LEC006,18,Data Science,53706,43.05891,-88.007462,pepperoni,dog,Yes,night owl,Yes +LEC006,,Engineering: Mechanical,53706,37.566536,126.977966,pepperoni,dog,Yes,night owl,No +LEC005,18,Data Science,53706,36.393154,25.46151,none (just cheese),dog,No,night owl,No +LEC001,,Engineering: Mechanical,53715,19.8968,155.5828,pepperoni,dog,No,night owl,No +LEC002,19,Engineering: Biomedical,53706,48.494904,-113.979034,macaroni/pasta,cat,No,night owl,Yes +LEC005,18,Engineering: Mechanical,53706,41.88998,12.49426,pineapple,dog,Yes,night owl,Yes +LEC003,17,Data Science,53706,-7.257472,112.75209,pineapple,dog,Yes,early bird,Yes +LEC005,19,Economics,53703,40.592331,-111.820152,none (just cheese),dog,Yes,night owl,Maybe +LEC005,19,Data Science,53704,38.722252,-9.139337,pepperoni,dog,No,night owl,Yes +LEC003,,Computer Science,53703,64.963051,-19.020836,pineapple,dog,No,no preference,Maybe +LEC002,20,Economics,53703,43.769562,11.255814,mushroom,dog,No,night owl,Yes +LEC004,20,Business: Actuarial,53715,44.834209,-87.376266,sausage,dog,No,no preference,Yes +LEC005,21,Economics,53703,37.751824,-122.420105,green pepper,cat,No,night owl,Yes +LEC004,22,Economics,53703,56.490669,4.202646,mushroom,dog,No,no preference,Yes +LEC004,18,Engineering: Mechanical,53706,44.9058,-93.28535,pepperoni,cat,Yes,night owl,Maybe +LEC004,19,Data Science,53703,41.878113,-87.629799,sausage,dog,No,night owl,Yes +LEC001,21,Computer Science,53703,43.21518,-87.94241,pepperoni,dog,No,no preference,Maybe +LEC004,24,Science: Chemistry,53703,32.715736,-117.161087,mushroom,dog,Yes,night owl,Maybe +LEC005,19,Engineering: Mechanical,53715,39.412327,-77.425461,pepperoni,cat,Yes,early bird,Yes +LEC004,20,Statistics,53703,43.07391,-89.39356,pepperoni,dog,No,early bird,Maybe +LEC005,21,Business: Finance,53703,38.178127,-92.781052,mushroom,dog,No,night owl,Yes +LEC004,18,Engineering: Mechanical,53706,35.689487,139.691711,pepperoni,dog,No,no preference,Yes +LEC005,18,Data Science,60521,41.9,87.6,pepperoni,dog,Yes,night owl,Yes +LEC005,23,Business: Information Systems,53558,43.073051,-89.40123,pepperoni,dog,Yes,early bird,No +LEC004,18,Engineering: Mechanical,53706,43.739507,7.426706,pepperoni,dog,No,night owl,Yes +LEC005,21,Data Science,53703,25,121,pepperoni,dog,No,night owl,Yes +LEC005,20,Business: Information Systems,53703,43.073051,-89.40123,pepperoni,dog,Yes,night owl,Yes +LEC004,,Engineering: Biomedical,53715,41.385063,2.173404,pepperoni,dog,Yes,no preference,No +LEC004,18,Communication arts,53715,22.543097,114.057861,mushroom,cat,Yes,early bird,Yes +LEC001,22,Engineering: Mechanical,53703,47.497913,19.040236,pepperoni,dog,No,no preference,No +LEC005,19,Computer Science,54706,34.05,-118.24,sausage,cat,Yes,night owl,Yes +LEC005,18,Engineering: Biomedical,53706,46.818188,8.227512,pineapple,dog,Yes,no preference,Yes +LEC004,19,Engineering: Mechanical,53715,42.36,-71.058884,pepperoni,dog,Yes,no preference,Yes +LEC005,21,Data Science,53703,36.4,117,pineapple,dog,Yes,night owl,Yes +LEC005,19,Engineering: Mechanical,53704,35.6762,139.6503,sausage,dog,No,night owl,Maybe +LEC004,20,Economics,53703,44.885,-93.147,pepperoni,dog,No,early bird,Yes +LEC004,20,Health Promotion and Health Equity,53704,48.8566,2.349014,pepperoni,dog,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53715,43.073051,-89.40123,sausage,dog,Yes,no preference,Yes +LEC001,20,Business andministration,53703,37.389091,-5.984459,pineapple,dog,Yes,night owl,Maybe +LEC003,23,Mathematics/AMEP,53715,24.88,102.8,pineapple,dog,Yes,early bird,Yes +LEC002,20,Engineering: Industrial,53703,44.389,12.9908,sausage,dog,No,early bird,Maybe +LEC005,20,Education,53703,41.878113,-87.629799,basil/spinach,cat,Yes,early bird,No +LEC003,19,Science: Biology/Life,53703,41.38,2.17,pepperoni,dog,Yes,no preference,Maybe +LEC006,18,Pre-business,53706,41.8781,87.6298,pepperoni,dog,Yes,night owl,Yes +LEC004,20,Business: Finance,53706,41.10475,-80.64916,basil/spinach,dog,Yes,night owl,Yes +LEC004,20,Statistics,53703,42.360081,-71.058884,pepperoni,dog,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53706,24.5554,81.7842,pepperoni,dog,No,early bird,Maybe +LEC004,19,Data Science,53703,38.72,75.07,none (just cheese),dog,Yes,early bird,Yes +LEC006,20,Engineering: Mechanical,53705,30.572815,104.066803,mushroom,cat,Yes,no preference,Maybe +LEC003,20,Mathematics/AMEP,53726,43.07199,-89.42629,mushroom,dog,No,night owl,Yes +LEC004,20,Engineering: Mechanical,53705,48,7.85,pepperoni,dog,Yes,night owl,No +LEC001,20,Computer Science,53703,40.7128,74.006,pepperoni,dog,Yes,night owl,Maybe +LEC003,18,Business: Actuarial,53719,14.599512,120.984222,pineapple,cat,Yes,no preference,Maybe +LEC003,17,Computer Science,53715,37.38522,-122.114128,Other,dog,No,night owl,No +LEC003,18,Computer Science,53706,37.386051,-122.083855,sausage,dog,Yes,no preference,Maybe +LEC004,23,Business: Finance,53703,31.230391,121.473701,mushroom,neither,No,night owl,No +LEC004,21,Engineering: Industrial,53703,37.94048,-78.63664,Other,dog,Yes,night owl,Yes +LEC002,21,Mathematics/AMEP,53715,42.360081,-71.058884,mushroom,neither,Yes,early bird,Yes +LEC002,18,Engineering: Industrial,53715,40.712776,-74.005974,pineapple,dog,Yes,night owl,Yes +LEC001,22,Engineering: Mechanical,53726,36.97447,122.02899,pepperoni,dog,No,no preference,Yes +LEC005,,Mathematics/AMEP,53715,36.651199,117.120094,mushroom,neither,No,night owl,Yes +LEC005,18,Mathematics/AMEP,53706,46.482525,30.723309,basil/spinach,dog,No,early bird,Yes +LEC006,20,Engineering: Industrial,53703,42.102901,-88.368896,pepperoni,dog,No,night owl,Maybe +LEC006,18,Computer Science,53706,-31.959153,-244.161255,green pepper,dog,No,night owl,Yes +LEC002,24,Computer Science,53715,30.704852,104.003904,mushroom,neither,Yes,no preference,Maybe +LEC005,19,Engineering: Mechanical,53705,40.712776,-74.005974,pepperoni,dog,No,early bird,No +LEC004,22,Science: Biology/Life,53705,39.758161,39.758161,pepperoni,cat,No,early bird,Yes +LEC005,20,Statistics,53703,43.073051,-89.40123,sausage,dog,Yes,night owl,Yes +LEC001,19,Data Science,53703,41,87,sausage,dog,No,no preference,No +LEC004,20,Engineering: Mechanical,53726,58.2996,14.4444,sausage,cat,No,night owl,Maybe +LEC005,18,Engineering: Mechanical,53562,1.3521,103.8198,green pepper,cat,No,early bird,Maybe +LEC002,19,Engineering: Mechanical,53703,44.46534,-72.684303,green pepper,cat,Yes,night owl,Yes +LEC002,20,Engineering: Industrial,53726,43.038902,-87.906471,pepperoni,dog,No,night owl,Yes +LEC006,18,Business: Actuarial,53706,45.464203,9.189982,pepperoni,cat,Yes,night owl,Yes +LEC006,18,Computer Science,53715,30.58198,114.268066,sausage,cat,Yes,early bird,Maybe +LEC004,19,Business: Finance,53706,41.878113,-87.629799,pepperoni,dog,No,early bird,No +LEC005,18,Business: Finance,53706,40.416775,-3.70379,pepperoni,dog,Yes,early bird,No +LEC001,20,Science: Other|Environmental Science,53715,41.878113,-87.629799,green pepper,cat,No,early bird,No +LEC002,22,Computer Science,53715,42,-71,mushroom,cat,No,night owl,Maybe +LEC001,24,Economics,53703,40,-90,pineapple,dog,No,night owl,Yes +LEC006,19,Business: Information Systems,53715,40.712776,-74.005974,basil/spinach,dog,No,night owl,Yes +LEC002,19,Data Science,53703,33.4942,89.4959,sausage,dog,No,night owl,Maybe +LEC003,20,Engineering: Mechanical,53715,43.02833,-87.971467,pepperoni,neither,Yes,night owl,Maybe +LEC001,,Data Science,53706,40.416775,-3.70379,none (just cheese),dog,Yes,no preference,Yes +LEC003,19,Engineering: Mechanical,53715,43.07,-89.4,pepperoni,dog,No,no preference,Maybe +LEC006,18,Data Science,53706,46.683334,7.85,mushroom,dog,Yes,no preference,No +LEC003,19,Engineering: Biomedical,53703,31.046051,34.851612,Other,dog,No,night owl,Maybe +LEC003,18,Data Science,53705,31.23,121.47,mushroom,dog,Yes,night owl,Maybe +LEC005,19,Engineering: Mechanical,53703,42.00741,-87.69384,mushroom,dog,No,night owl,Yes +LEC001,37,Data Science,53718,43.073051,-89.40123,green pepper,dog,No,no preference,Maybe +LEC003,20,History,53703,31.62,74.8765,Other,cat,Yes,early bird,No +LEC002,20,Economics,53703,38.627003,-90.199402,mushroom,dog,Yes,night owl,Yes +LEC005,20,Engineering: Mechanical,53703,40,-74,none (just cheese),dog,Yes,early bird,No +LEC005,18,Data Science,53706,23.7275,37.9838,pepperoni,dog,Yes,early bird,Yes +LEC004,20,Mathematics/AMEP,53703,34.746613,113.625328,sausage,neither,Yes,early bird,Maybe +LEC001,21,Data Science,53703,30.572351,121.776761,pepperoni,cat,No,night owl,Maybe +LEC005,,Data Science,53715,35.72,-78.89,pepperoni,dog,No,night owl,Yes +LEC005,20,Information science,53590,44.92556,-89.51539,pepperoni,dog,No,night owl,Yes +LEC002,22,Mathematics/AMEP,53704,40.76078,-111.891045,pineapple,dog,Yes,night owl,No +LEC001,22,consumer behavior and marketplace studies,53715,43.653225,-79.383186,mushroom,cat,Yes,night owl,No +LEC004,22,Computer Science,53703,10.315699,123.885437,sausage,dog,Yes,early bird,No +LEC002,20,Conservation Biology,53703,40.16573,-105.101189,pineapple,dog,No,night owl,Yes +LEC005,20,Computer Science,53726,39.4817,106.0384,Other,neither,Yes,early bird,Yes +LEC005,19,Mathematics/AMEP,53715,48.85,2.35,sausage,cat,No,night owl,Maybe +LEC005,19,Data Science,53706,30.572815,104.066803,mushroom,neither,No,early bird,Yes +LEC004,24,Business: Information Systems,53703,37.566536,126.977966,tater tots,dog,No,early bird,No +LEC004,19,Economics,53703,52.877491,-118.08239,pepperoni,dog,No,night owl,Yes +LEC004,21,Computer Science,53703,28.538336,-81.379234,pepperoni,dog,No,night owl,Yes +LEC006,18,Data Science,53706,41.4,-81.9,sausage,dog,Yes,night owl,Maybe +LEC002,21,Science: Biology/Life,53703,43.038902,-87.906471,none (just cheese),neither,No,no preference,Yes +LEC004,21,Data Science,53703,3.86,-54.2,macaroni/pasta,dog,No,early bird,No +LEC004,19,Engineering: Mechanical,53715,39.952583,-75.165222,macaroni/pasta,dog,Yes,no preference,Yes +LEC004,20,Science: Other,53715,21.3099,157.8581,pineapple,dog,No,early bird,Yes +LEC005,21,Data Science,48823,11.451419,19.81,mushroom,neither,No,night owl,Maybe +LEC001,20,Computer Science,53715,41,-87,Other,dog,No,night owl,Yes +LEC005,21,Data Science,53705,42.3601,71.0589,pepperoni,dog,Yes,no preference,Yes +LEC005,19,Computer Science,53706,48.856613,2.352222,pepperoni,dog,Yes,night owl,Maybe +LEC001,17,Statistics,53715,43.0722,89.4008,pineapple,dog,No,early bird,Maybe +LEC001,20,Economics,53715,27.99942,120.66682,pepperoni,dog,Yes,early bird,No +LEC001,19,Mathematics/AMEP,53711,45.85038,-84.616989,pineapple,cat,No,night owl,Yes +LEC004,20,Computer Science,53711,40.842358,111.749992,pineapple,cat,No,night owl,Maybe +LEC003,18,Engineering: Mechanical,53706,39.738449,-104.984848,pepperoni,dog,No,early bird,Yes +LEC003,21,Statistics,53705,41.878113,-87.629799,macaroni/pasta,dog,No,night owl,Yes +LEC006,19,Engineering: Industrial,60540,41.878113,-87.629799,none (just cheese),dog,No,night owl,No +LEC004,19,Engineering: Mechanical,53703,40.6263,14.3758,mushroom,dog,No,early bird,No +LEC004,22,Engineering: Other|Chemical Engineering,53703,48.13913,11.58022,macaroni/pasta,dog,Yes,night owl,Yes +LEC004,21,Economics (Mathematical Emphasis),53703,52.520008,13.404954,pepperoni,dog,No,night owl,No +LEC004,25,Science: Other|Biophysics PhD,53705,30.21161,-97.80999,pineapple,dog,No,night owl,Yes +LEC003,19,Computer Science,53716,25.49443,-103.59581,pepperoni,cat,No,no preference,Yes +LEC003,19,Data Science,53706,64.963051,-19.020836,pineapple,dog,No,no preference,No +LEC006,19,Computer Science,53706,41.878113,-87.629799,pepperoni,cat,No,night owl,Maybe +LEC001,23,Economics,53703,43.07348,-89.38089,pepperoni,dog,No,night owl,Yes +LEC001,29,Business: Other|Technology Strategy/ Product Management,53705,37.386051,-122.083855,Other,cat,No,no preference,Maybe +LEC002,,Engineering: Mechanical,53706,14.34836,100.576271,pepperoni,neither,No,no preference,Maybe +LEC004,20,Undecided,53715,37.566536,126.977966,none (just cheese),neither,No,night owl,Yes +LEC006,19,Engineering: Mechanical,53703,27.993828,120.699364,sausage,neither,No,no preference,Yes +LEC002,,Computer Science,53705,25.032969,121.565414,pineapple,dog,No,night owl,Yes +LEC005,20,Mathematics/AMEP,53703,32.060253,118.796875,pineapple,cat,Yes,night owl,Maybe +LEC003,,Business: Other,53706,50.07553,14.4378,pepperoni,dog,Yes,night owl,Maybe +LEC006,21,Data Science,57303,32.715736,-117.161087,macaroni/pasta,cat,Yes,no preference,Yes +LEC006,18,Engineering: Mechanical,53706,45.5579,94.1632,sausage,dog,No,night owl,Yes +LEC001,18,Engineering: Biomedical,53715,43.073051,-89.40123,sausage,dog,No,early bird,Yes +LEC005,19,Engineering: Mechanical,53706,38.571739,-109.550797,pepperoni,cat,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53706,41.902782,12.496365,pepperoni,dog,Yes,night owl,No +LEC002,21,Data Science,53711,120,30,sausage,dog,Yes,night owl,Maybe +LEC004,18,Engineering: Biomedical,53706,40.014984,-105.270546,green pepper,dog,No,night owl,Yes +LEC004,20,Engineering: Mechanical,53715,53.2779,6.1058,sausage,dog,Yes,no preference,Yes +LEC003,17,Science: Physics,53706,50.088153,14.399437,Other,cat,No,night owl,Yes +LEC002,19,Engineering: Industrial,53705,35.084385,-106.650421,pineapple,cat,No,night owl,Yes +LEC003,20,Engineering: Mechanical,53703,44.501343,-88.06221,pepperoni,dog,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53703,45.659302,-92.466164,macaroni/pasta,dog,No,no preference,Maybe +LEC003,19,Data Science,53703,16.896721,42.5536,none (just cheese),neither,No,early bird,Maybe +LEC001,18,Data Science,53703,23.885942,45.079163,mushroom,neither,No,early bird,Maybe +LEC006,19,Engineering: Mechanical,53703,55.953251,-3.188267,mushroom,cat,Yes,night owl,Yes +LEC001,30,Business: Other,53705,43.07175,-89.46498,pineapple,cat,No,early bird,No +LEC006,18,Political Science,53706,39.640263,-106.374191,green pepper,dog,No,early bird,No +LEC005,23,Business: Information Systems,53705,27.99,120.69,green pepper,dog,No,night owl,No +LEC003,18,Graphic Design,53706,40.713051,-74.007233,Other,dog,Yes,early bird,Yes +LEC002,21,Economics,53715,37.369171,-122.112473,mushroom,dog,No,night owl,No +LEC005,18,Computer Science,53706,21.3099,157.8581,pepperoni,cat,No,night owl,Yes +LEC002,19,Business: Other|Marketing,53706,59.913868,10.752245,macaroni/pasta,dog,No,night owl,Maybe +LEC003,20,Cartography and GIS,53726,43.0722,89.4008,sausage,cat,No,early bird,Maybe +LEC005,21,Economics,53705,25.032969,120.960518,sausage,dog,Yes,night owl,Maybe +LEC005,19,Engineering: Industrial,53703,42.03992,87.67732,sausage,dog,Yes,night owl,Yes +LEC003,,Computer Science,53706,35.443081,139.362488,sausage,dog,Yes,night owl,Yes +LEC002,22,Sociology,53703,53.483959,-2.244644,pepperoni,dog,No,night owl,Yes +LEC002,18,Undecided,53706,43.073051,-89.40123,pineapple,dog,Yes,night owl,Yes +LEC004,19,Engineering: Biomedical,53706,-37.81,144.96,sausage,dog,Yes,night owl,Yes +LEC005,21,Mathematics/AMEP,53703,22.542883,114.062996,pepperoni,cat,No,no preference,Maybe +LEC002,20,Statistics,53715,23,113,pineapple,dog,No,night owl,Maybe +LEC001,20,Business: Other|Consumer Behavior and Marketplace Studies,53703,40.76078,-111.891045,green pepper,dog,Yes,early bird,Maybe +LEC001,21,Data Science,53705,40.712776,-74.005974,pepperoni,cat,No,night owl,Maybe +LEC002,19,Engineering: Mechanical,53703,26.345631,-81.779083,pepperoni,dog,Yes,night owl,Yes +LEC004,19,Engineering: Mechanical,53715,40.62632,14.37574,pepperoni,dog,No,no preference,Maybe +LEC003,18,Engineering: Other,53706,40.73061,-73.9808,mushroom,dog,No,night owl,No +LEC006,18,Atmospheric Sciences,53706,39.74,-104.99,sausage,dog,Yes,night owl,Maybe +LEC002,20,Data Science,53703,43.073051,-89.40123,macaroni/pasta,dog,Yes,early bird,Yes +LEC006,18,Engineering: Mechanical,53706,32.7157,117.1611,pineapple,dog,Yes,night owl,Yes +LEC004,18,Computer Science,53706,51.507351,-0.127758,green pepper,dog,No,night owl,Yes +LEC004,19,Education,53715,32.715736,-117.161087,pepperoni,dog,No,night owl,Yes +LEC004,26,Languages,53703,50.11,8.68,sausage,dog,No,no preference,Yes +LEC005,21,Economics (Mathematical Emphasis),53715,55.676098,12.568337,pepperoni,cat,No,night owl,Maybe +LEC004,53,Mathematics/AMEP,53555,47.6,-122.3,mushroom,dog,No,night owl,Yes +LEC004,17,Computer Science,53706,43.073051,-89.40123,Other,dog,No,night owl,Yes +LEC006,18,Engineering Mechanics (Aerospace Engineering),53706,43.038902,-87.906471,pepperoni,cat,No,night owl,No +LEC002,20,Engineering: Mechanical,53715,23.7157,117.1611,none (just cheese),cat,Yes,night owl,Maybe +LEC002,22,Science: Other|Psychology,53703,37.82034,-122.47872,mushroom,dog,No,early bird,No +LEC002,22,Computer Science,53705,34.052235,-118.243683,basil/spinach,dog,No,night owl,Yes +LEC004,26,Science: Biology/Life,53715,33.962425,-83.378622,pineapple,neither,Yes,no preference,Yes +LEC002,18,Economics,53715,41.878113,-87.629799,basil/spinach,cat,No,night owl,Maybe +LEC004,24,Engineering: Other|Civil and Environmental Engineering,53703,47.5,19.04,pepperoni,dog,Yes,early bird,Maybe +LEC004,19,Engineering: Biomedical,53711,40.712776,74.005974,pineapple,dog,No,early bird,No +LEC001,19,Engineering: Mechanical,53715,43,-90,sausage,dog,No,no preference,Maybe +LEC006,18,Data Science,94707,37.566536,126.977966,pineapple,dog,Yes,night owl,Yes +LEC006,20,Undecided,53719,62.2001,58.9638,Other,cat,Yes,night owl,Maybe +LEC002,18,Engineering: Mechanical,53706,44.977753,-93.265015,none (just cheese),cat,Yes,night owl,Yes +LEC001,20,Business: Information Systems,53711,34.385204,132.455292,pepperoni,dog,No,early bird,Yes +LEC005,19,Engineering: Biomedical,53703,41.8781,87.6298,macaroni/pasta,dog,No,night owl,No +LEC002,19,Engineering: Biomedical,53703,37.98381,23.727539,macaroni/pasta,dog,No,night owl,Maybe +LEC005,18,Data Science,53706,40,74,pepperoni,dog,No,no preference,Yes +LEC002,19,Engineering: Mechanical,53711,41.95881,-85.32536,Other,dog,No,no preference,No +LEC005,18,Data Science,53706,32.715736,-117.161087,sausage,dog,No,night owl,Maybe +LEC002,18,Undecided,53706,43.060791,-88.119217,Other,neither,No,early bird,Yes +LEC004,21,Science: Other,53715,27.963989,-82.799957,pineapple,dog,No,night owl,Yes +LEC006,18,Data Science,53706,1.352083,103.819839,sausage,dog,No,night owl,Yes +LEC005,19,Data Science,53703,-33.92487,18.424055,none (just cheese),dog,No,night owl,Yes +LEC001,22,International Studies,53703,48.13913,11.58022,none (just cheese),cat,No,night owl,Yes +LEC001,19,Engineering: Other,53715,38.331581,-75.086159,macaroni/pasta,dog,No,no preference,Yes +LEC002,19,Business: Information Systems,53715,44.5,-88,pepperoni,dog,No,night owl,Yes +LEC002,19,Data Science,53705,21.59143,-158.01743,Other,dog,Yes,night owl,Yes +LEC002,,Business: Finance,53593,45.813042,9.080931,Other,dog,No,early bird,Yes +LEC003,21,Business: Information Systems,53703,43.612255,-110.705429,sausage,dog,Yes,no preference,No +LEC001,21,Data Science,53703,41.00824,28.978359,pepperoni,cat,Yes,early bird,No +LEC002,18,Engineering: Biomedical,53706,17.385044,78.486671,green pepper,dog,No,night owl,Yes +LEC006,21,Political Science,53703,45.512,-122.658,sausage,dog,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53706,41.902782,12.496365,pepperoni,dog,No,early bird,Maybe +LEC005,19,Engineering: Mechanical,53703,-36.848461,174.763336,none (just cheese),dog,Yes,no preference,No +LEC002,,Data Science,53713,30.316496,78.032188,mushroom,cat,Yes,night owl,Yes +LEC002,,Business: Information Systems,53703,35.689487,139.691711,sausage,dog,Yes,night owl,Maybe +LEC005,18,Data Science,53706,52.520008,13.404954,pineapple,dog,Yes,early bird,No +LEC005,19,Computer Science,53706,41.3784,2.1686,sausage,cat,No,no preference,Yes +LEC003,20,Engineering: Mechanical,53715,41.878113,-87.629799,Other,cat,No,night owl,Yes +LEC004,20,Computer Science,53703,43.073051,-89.40123,none (just cheese),cat,Yes,night owl,Yes +LEC006,23,Data Science,53703,17.05423,-96.713226,basil/spinach,dog,No,night owl,Maybe +LEC001,19,Engineering: Mechanical,53706,43.77195,-88.43383,pepperoni,dog,No,early bird,Maybe +LEC001,20,Economics,53726,42.92,-87.96,pepperoni,dog,Yes,early bird,No +LEC001,19,Engineering: Mechanical,53715,29.424122,-98.493629,mushroom,dog,Yes,early bird,Maybe +LEC004,18,Computer Science,53706,30.267153,-97.743057,pepperoni,dog,No,night owl,Yes +LEC005,,Computer Science,53715,44.9778,93.265,sausage,cat,Yes,night owl,Yes +LEC003,19,Science: Other,53715,41.9028,12.4964,pepperoni,dog,No,night owl,Yes +LEC004,19,Data Science,53715,61.2176,149.8997,pineapple,cat,Yes,night owl,Maybe +LEC001,20,Agricultural and Applied Economics,53703,-22.932924,-47.073845,pineapple,cat,Yes,early bird,Maybe +LEC003,18,Computer Science,53706,52.370216,4.895168,basil/spinach,cat,No,night owl,Maybe +LEC003,19,Engineering: Industrial,53703,5.838715,3.603516,pepperoni,dog,Yes,early bird,No +LEC005,19,Engineering: Mechanical,53715,48.502281,-113.988533,sausage,dog,No,night owl,Yes +LEC004,41,Languages,53705,29.654839,91.140549,pepperoni,cat,No,night owl,Yes +LEC002,21,Business: Other|MHR,53703,44,125,Other,neither,No,night owl,Maybe +LEC005,24,Business: Other,53703,43.073051,-89.40123,pineapple,dog,No,night owl,Yes +LEC002,18,Undecided,53706,46.786671,-92.100487,none (just cheese),cat,No,no preference,Yes +LEC004,18,Engineering: Biomedical,53705,35.689487,139.691711,basil/spinach,dog,No,night owl,Yes +LEC001,25,Medicine,53703,48.38203,-123.537827,basil/spinach,dog,Yes,early bird,No +LEC004,19,Science: Biology/Life,53705,46.009991,-91.482094,pineapple,dog,No,early bird,No +LEC005,21,Science: Other|Personal Finance,53703,28.228209,112.938812,pepperoni,cat,Yes,night owl,Yes +LEC004,18,Data Science,53706,35.689487,139.691711,pepperoni,dog,No,night owl,Maybe +LEC006,21,Mathematics/AMEP,53703,41.878113,-87.629799,pineapple,cat,Yes,night owl,Maybe +LEC005,18,Environmental science,53706,31.224361,121.46917,mushroom,dog,No,night owl,Yes +LEC005,18,Engineering: Industrial,53706,40.712776,-74.005974,pepperoni,dog,Yes,night owl,Yes +LEC001,20,Business: Other|Real Estate,53703,51.5,0.128,mushroom,dog,Yes,no preference,Maybe +LEC001,19,Computer Science,53706,40,-74,pepperoni,cat,No,night owl,Yes +LEC003,19,Engineering: Mechanical,53715,44,-94,pineapple,dog,No,early bird,No +LEC001,19,Data Science,53715,40.712776,-74.005974,pepperoni,dog,No,early bird,No +LEC005,18,Engineering: Industrial,53703,41.385063,2.173404,pepperoni,dog,Yes,no preference,Yes +LEC002,20,Engineering: Industrial,53715,22.3,91.8,sausage,cat,Yes,early bird,Maybe +LEC001,24,Engineering: Industrial,53705,13.100485,77.594009,none (just cheese),dog,Yes,no preference,Maybe +LEC004,19,Statistics,53706,36.778259,-119.417931,pineapple,cat,No,night owl,Yes +LEC005,21,Economics,53703,40.016869,-105.279617,pepperoni,cat,Yes,night owl,Yes +LEC003,19,Economics (Mathematical Emphasis),53705,31.230391,121.473701,sausage,neither,Yes,no preference,Maybe +LEC003,19,Business: Finance,53706,22.270979,113.576675,pepperoni,dog,Yes,night owl,Yes +LEC003,21,Computer Science,53705,43.073051,-89.40123,green pepper,cat,No,no preference,Maybe +LEC001,28,Science: Biology/Life,53703,7.190708,125.455338,sausage,dog,No,night owl,Yes +LEC004,18,Statistics,53703,60.472023,8.468946,none (just cheese),dog,No,early bird,No +LEC002,19,Computer Science,53715,41.73993,-88.09423,mushroom,cat,Yes,no preference,Yes +LEC002,21,Economics,53703,26.074301,119.296539,mushroom,cat,No,no preference,Maybe +LEC002,20,Engineering: Industrial,53715,2.188477,41.379179,sausage,dog,No,night owl,Yes +LEC003,21,Science: Other|Environmental Science,53703,20.8,-156.3,basil/spinach,cat,No,early bird,Maybe +LEC006,18,Engineering: Mechanical,53706,25.204849,55.270782,pepperoni,dog,No,night owl,Yes +LEC002,18,Data Science,53706,42.360081,-71.058884,sausage,dog,Yes,night owl,Yes +LEC004,23,Engineering: Mechanical,53703,38.82097,-104.78163,sausage,dog,No,night owl,No +LEC001,19,Engineering: Industrial,53715,47.606209,-122.332069,pepperoni,cat,No,night owl,No +LEC006,19,Sociology,53703,43.05977,-87.88491,basil/spinach,dog,No,night owl,Maybe +LEC005,19,Engineering: Mechanical,53711,38.8951,-77.0364,pepperoni,dog,Yes,night owl,No +LEC005,19,Engineering: Mechanical,53703,41.881832,87.6298,pepperoni,dog,No,no preference,Yes +LEC002,20,Engineering: Mechanical,53703,46.453825,7.436478,pineapple,dog,Yes,night owl,Yes +LEC002,20,Economics,53703,30.49996,117.050003,Other,dog,No,early bird,Maybe +LEC004,21,Science: Other|Psychology,53715,23.12911,113.264381,none (just cheese),cat,No,night owl,Maybe +LEC002,18,Science: Biology/Life,53706,40.7831,73.9712,basil/spinach,dog,Yes,night owl,Yes +LEC002,,Business: Information Systems,53706,18.52043,73.856743,green pepper,dog,No,night owl,Yes +LEC002,,Computer Science,53706,29.424122,-98.493629,none (just cheese),dog,No,no preference,Yes +LEC002,20,Engineering: Mechanical,53703,41.05995,-80.32312,basil/spinach,dog,Yes,night owl,Maybe +LEC006,19,Statistics,53715,3.139003,101.686852,mushroom,cat,No,no preference,Maybe +LEC005,18,Data Science,53706,52.370216,4.895168,basil/spinach,dog,No,night owl,Yes +LEC006,19,Engineering: Industrial,53706,41.878113,-87.629799,pepperoni,dog,No,no preference,Maybe +LEC006,18,Business: Information Systems,53706,25.032969,121.565414,mushroom,dog,Yes,night owl,Yes +LEC001,17,Computer Science,53726,21.027763,105.83416,pepperoni,dog,No,early bird,Yes +LEC001,20,Business: Information Systems,53711,45.046799,-87.298149,sausage,cat,No,night owl,Yes +LEC005,25,Engineering: Other,53705,32.7157,-117.1611,mushroom,dog,No,no preference,Yes +LEC004,18,Engineering: Industrial,53706,19.896767,-155.582779,pepperoni,dog,Yes,night owl,Maybe +LEC005,18,Computer Science,53706,1.28217,103.865196,sausage,dog,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53706,44.977753,-93.265015,pepperoni,dog,No,night owl,Yes +LEC004,20,Engineering: Mechanical,53715,23,90,green pepper,cat,No,no preference,Yes +LEC005,20,Data Science,53703,45.259546,-84.938476,mushroom,dog,Yes,night owl,Yes +LEC002,21,Science: Other,53703,41.878113,-87.629799,pineapple,dog,Yes,early bird,No +LEC004,19,Information science,53703,40.712776,-74.005974,pineapple,cat,Yes,early bird,Maybe +LEC001,19,Engineering: Mechanical,53715,64.126518,-21.817438,pepperoni,dog,No,night owl,Yes +LEC003,,Business: Other,53706,42.360081,-71.058884,sausage,cat,Yes,night owl,No +LEC002,31,Geoscience,53703,-41.126621,-73.059303,pepperoni,cat,No,night owl,Yes +LEC003,18,Engineering: Biomedical,53706,45.17099,-87.16494,Other,dog,No,night owl,Maybe +LEC002,18,Engineering: Mechanical,53706,37.774929,-122.419418,Other,dog,Yes,no preference,Yes +LEC004,,Computer Science,53715,39.70698,-86.0862,mushroom,cat,No,night owl,Yes +LEC005,20,Science: Biology/Life,53703,44.276402,-88.26989,macaroni/pasta,cat,No,no preference,Maybe +LEC002,19,Science: Biology/Life,53703,51.492519,-0.25852,sausage,dog,Yes,no preference,Yes +LEC002,19,Data Science,53703,37.6,14.0154,none (just cheese),dog,No,night owl,Yes +LEC002,20,Engineering: Industrial,53715,46.685631,7.8562,Other,cat,No,night owl,Maybe +LEC002,22,Economics,53706,41.385063,2.173404,pineapple,cat,No,night owl,Maybe +LEC004,21,Engineering: Industrial,53703,41.878113,-87.629799,pepperoni,neither,Yes,early bird,No +LEC004,19,Engineering: Mechanical,53703,51.507351,-0.127758,none (just cheese),neither,No,no preference,Maybe +LEC006,18,Engineering: Mechanical,53706,41.077747,1.131593,sausage,dog,No,no preference,Maybe +LEC006,18,Engineering: Mechanical,53706,43.526,5.445,basil/spinach,dog,Yes,no preference,Yes +LEC003,22,Economics,53715,43.073051,-89.40123,pepperoni,dog,Yes,early bird,Yes +LEC005,18,Engineering: Industrial,53706,43.085369,-88.912086,sausage,dog,No,night owl,Maybe +LEC002,19,Statistics,53703,43.769562,11.255814,basil/spinach,dog,No,no preference,Yes +LEC001,20,Computer Science,53715,20.880947,-156.681862,sausage,dog,No,night owl,Yes +LEC003,19,Mathematics/AMEP,53703,64.963051,-19.020836,basil/spinach,dog,No,no preference,Yes +LEC005,18,Undecided,53706,43.073929,-89.385239,sausage,dog,Yes,early bird,Yes +LEC003,18,Business: Information Systems,53706,25.204849,55.270782,none (just cheese),dog,No,night owl,No +LEC003,21,Economics,53703,39.904,116.407,pepperoni,cat,No,night owl,No +LEC004,18,Engineering: Mechanical,53706,39.739235,-104.99025,pepperoni,cat,Yes,no preference,Maybe +LEC004,21,Science: Biology/Life,53726,43,89,pepperoni,dog,Yes,night owl,Yes +LEC003,19,Data Science,53715,43.073051,-89.40123,none (just cheese),dog,No,early bird,Maybe +LEC002,19,Business: Other|accounting,53703,43.38,-87.9,sausage,neither,No,night owl,Yes +LEC002,18,Science: Biology/Life,53706,40.122,25.4988,sausage,dog,No,early bird,No +LEC005,20,Engineering: Mechanical,53715,39.904202,116.407394,sausage,dog,No,night owl,Yes +LEC001,19,Engineering: Mechanical,53703,-37.813629,144.963058,sausage,dog,Yes,night owl,Yes +LEC005,21,Economics,53715,46.81,-71.21,pepperoni,cat,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53715,52.370216,4.895168,mushroom,dog,Yes,night owl,Yes +LEC001,21,Mathematics/AMEP,53703,34.29006,108.932941,basil/spinach,dog,No,early bird,Yes +LEC005,21,Engineering: Mechanical,53726,43.804801,-91.226075,pepperoni,dog,Yes,night owl,Yes +LEC002,18,Data Science,53703,32.715736,-117.161087,none (just cheese),cat,Yes,night owl,Maybe +LEC004,18,Engineering: Mechanical,53706,20.92674,-156.69386,pepperoni,dog,No,night owl,Maybe +LEC003,18,Data Science,53706,47.606209,-122.332069,pepperoni,dog,No,early bird,Yes +LEC005,21,Computer Science,53703,43.07515,-89.3958,sausage,neither,Yes,night owl,Yes +LEC001,19,Engineering: Mechanical,53562,43.096851,-89.511528,sausage,dog,No,night owl,No +LEC003,19,Engineering: Mechanical,53715,20.924325,-156.690102,sausage,cat,Yes,night owl,No +LEC005,20,Data Science,53703,25.0838,77.3212,pepperoni,dog,No,night owl,Maybe +LEC003,21,Business: Actuarial,53715,43.073051,-89.40123,pineapple,cat,Yes,night owl,Yes +LEC001,,Computer Science,53715,31.469279,119.765621,pepperoni,dog,No,night owl,Maybe +LEC005,19,Engineering: Mechanical,53715,43.769562,11.255814,basil/spinach,neither,No,early bird,No +LEC001,21,Science: Chemistry,53715,38.892059,-77.019913,pepperoni,neither,No,night owl,Yes +LEC002,19,Business: Finance,53715,42.360081,-71.058884,mushroom,dog,Yes,night owl,Yes +LEC001,18,Data Science,53703,24.713552,46.675297,none (just cheese),neither,No,night owl,Yes +LEC003,19,Business: Actuarial,53715,60.391262,5.322054,pepperoni,dog,No,early bird,No +LEC003,19,Data Science,53715,23.697809,120.960518,pepperoni,cat,No,night owl,Yes +LEC003,18,Data Science,53706,40.712776,74.005974,pineapple,dog,Yes,early bird,No +LEC004,19,Engineering: Mechanical,53703,45.126887,-94.528067,sausage,dog,No,night owl,Maybe +LEC002,21,Science: Biology/Life,53715,48.208176,16.373819,Other,dog,Yes,night owl,No +LEC006,18,Engineering: Mechanical,53706,44.0628,-121.30451,pepperoni,dog,No,night owl,Yes +LEC003,21,Statistics,53703,31.230391,121.473701,pineapple,cat,Yes,night owl,Yes +LEC005,21,Economics,53703,47.62772,-122.51368,macaroni/pasta,cat,No,no preference,No +LEC003,19,Engineering: Mechanical,53715,65.68204,-18.090534,sausage,cat,No,no preference,No +LEC004,21,Economics,53715,48.856613,2.352222,basil/spinach,dog,Yes,night owl,No +LEC001,18,Engineering: Biomedical,53706,33.501324,-111.925278,pineapple,dog,Yes,early bird,No +LEC005,18,Data Science,53706,14.77046,-91.183189,mushroom,cat,No,night owl,Maybe +LEC002,18,Engineering: Industrial,53706,10.480594,-66.903603,mushroom,neither,No,night owl,Maybe +LEC004,21,Engineering: Mechanical,53715,48.856613,2.352222,mushroom,cat,Yes,night owl,Yes +LEC001,19,Science: Biology/Life,53706,20.788602,-156.003662,green pepper,dog,Yes,no preference,No +LEC006,18,Data Science,53706,36.59239,-121.86875,pepperoni,cat,No,night owl,Maybe +LEC002,,Engineering: Industrial,53705,47.6,-122.33,sausage,dog,No,early bird,No +LEC001,18,Engineering: Mechanical,53703,23.885942,45.079163,Other,cat,No,night owl,Maybe +LEC002,18,Engineering: Industrial,53532,47.606209,-122.332069,mushroom,dog,No,night owl,Maybe +LEC002,17,Engineering: Biomedical,53706,39.5755,-106.100403,pepperoni,dog,Yes,night owl,Maybe +LEC002,20,Data Science,53711,39.904202,116.407394,pepperoni,dog,No,night owl,Yes +LEC001,19,Engineering: Industrial,53705,41.878113,-87.629799,tater tots,cat,No,night owl,No +LEC004,19,Political Science,53703,55.679626,12.581921,pepperoni,dog,Yes,no preference,Maybe +LEC005,18,Computer Science,53715,28.538336,-81.379234,pepperoni,dog,No,night owl,Maybe +LEC004,29,Engineering: Mechanical,53704,50.064651,19.944981,sausage,dog,No,early bird,Maybe +LEC005,18,Engineering: Other,53706,41.385063,2.173404,mushroom,cat,No,night owl,Yes +LEC001,19,Engineering: Mechanical,53703,44.977753,-93.265015,Other,cat,Yes,early bird,No +LEC001,32,Design Studies,53705,48.856613,2.352222,mushroom,dog,No,early bird,Yes +LEC002,20,Engineering: Mechanical,53703,41.28347,-70.099449,pepperoni,dog,Yes,night owl,Yes +LEC003,19,Engineering: Industrial,53715,41.73849,-71.30418,pepperoni,dog,No,night owl,Yes +LEC001,18,Data Science,53706,43.073051,-89.40123,sausage,dog,No,early bird,Yes +LEC001,19,Computer Science,53715,31.230391,121.473701,pineapple,cat,No,night owl,Yes +LEC001,19,Data Science,53703,37.9838,23.7275,sausage,dog,Yes,no preference,Yes +LEC005,20,Engineering: Biomedical,53703,47.497913,19.040236,Other,cat,Yes,night owl,No +LEC004,18,Economics,53711,13.756331,100.501762,Other,dog,No,night owl,Maybe +LEC002,18,Data Science,53706,3.864255,73.388672,pepperoni,dog,Yes,night owl,Maybe +LEC006,18,Engineering: Mechanical,53706,32.715736,-117.161087,macaroni/pasta,dog,Yes,night owl,Yes +LEC001,19,Business: Actuarial,53715,18.32431,64.941612,pepperoni,dog,No,no preference,Yes +LEC001,22,Psychology,53711,43.055333,-89.425946,pineapple,dog,Yes,early bird,No +LEC003,18,Computer Science,53706,40.744678,-73.758072,mushroom,cat,No,night owl,Maybe +LEC006,18,Data Science,53715,38.9784,76.4922,mushroom,cat,No,early bird,Yes +LEC004,20,Science: Other,53726,55.675758,12.56902,none (just cheese),cat,Yes,night owl,Yes +LEC001,20,Science: Biology/Life,53715,40.713051,-74.007233,pineapple,cat,No,night owl,Maybe +LEC004,18,Engineering: Industrial,53706,51.507351,-0.127758,pepperoni,dog,Yes,no preference,No +LEC004,25,Computer Science,53703,38.736946,-9.142685,pepperoni,dog,No,night owl,Yes +LEC002,18,Computer Science,53706,22.543097,114.057861,pepperoni,cat,No,no preference,Yes +LEC004,25,Science: Chemistry,53703,37.566536,126.977966,Other,cat,Yes,night owl,Maybe +LEC002,19,Engineering: Mechanical,53715,26.338,-81.775,pepperoni,dog,Yes,no preference,Maybe +LEC005,19,Engineering: Mechanical,53715,33.448376,-112.074036,pepperoni,neither,Yes,early bird,No +LEC005,19,Engineering: Mechanical,53703,43.073051,-89.40123,pepperoni,cat,No,no preference,Yes +LEC001,19,Engineering: Mechanical,53705,26.647661,106.63015,mushroom,cat,No,night owl,No +LEC003,18,Undecided,53706,43.2967,87.9876,pepperoni,dog,No,night owl,No +LEC005,19,Science: Physics,53703,78.225,15.626,sausage,cat,No,early bird,No +LEC002,,Science: Other|Environmetal Science,53703,52.973558,-9.425102,none (just cheese),dog,Yes,night owl,Maybe +LEC006,19,Economics (Mathematical Emphasis),53715,37.774929,-122.419418,sausage,cat,Yes,night owl,Yes +LEC002,20,Business: Finance,53703,40.7128,74.006,pineapple,dog,No,night owl,Yes +LEC001,21,Science: Biology/Life,53703,44.794,-93.148,pepperoni,dog,No,night owl,No +LEC002,19,Engineering: Mechanical,53706,36.17,-115.14,pepperoni,cat,No,night owl,Maybe +LEC001,18,Engineering: Biomedical,53706,21.161907,-86.851524,none (just cheese),dog,No,early bird,Maybe +LEC001,18,Computer Science,53715,48.856613,2.352222,pineapple,neither,Yes,no preference,No +LEC004,19,Engineering: Mechanical,53715,48.137,11.576,green pepper,dog,No,early bird,No +LEC001,20,Engineering: Biomedical,53703,43.07393,-89.38524,sausage,dog,No,night owl,Maybe +LEC002,18,Science: Other,53706,35.6762,139.6503,Other,dog,No,no preference,Yes +LEC004,19,Computer Science,53703,41.902782,12.496365,none (just cheese),neither,Yes,night owl,No +LEC001,20,Science: Other|Atmospheric and Oceanic Sciences (AOS),53711,49.299171,19.94902,pepperoni,dog,No,night owl,Maybe +LEC002,18,Data Science,53706,41.380898,2.12282,pepperoni,dog,No,night owl,Maybe +LEC006,18,Data Science,53706,48.257919,4.03073,mushroom,cat,Yes,early bird,No +LEC005,19,Engineering: Mechanical,53715,35.0844,106.6504,pineapple,dog,Yes,early bird,Yes +LEC002,23,Economics,53703,121,5,pepperoni,neither,No,no preference,Maybe +LEC004,18,Business: Actuarial,53706,21.306944,-157.858337,pineapple,dog,Yes,night owl,Maybe +LEC005,18,Economics,53706,43,-87.9,pepperoni,dog,Yes,early bird,Maybe +LEC005,23,Business: Other|Business Analytics,53703,31.230391,121.473701,pineapple,cat,Yes,night owl,Maybe +LEC002,22,Psychology,53703,25.032969,121.565414,mushroom,dog,No,no preference,Yes +LEC005,18,Computer Science,53706,43.0722,89.4008,sausage,cat,No,night owl,Yes +LEC006,18,Data Science,53706,52.370216,4.895168,mushroom,dog,Yes,night owl,Maybe +LEC004,20,Data Science,53703,35.726212,-83.491226,pepperoni,cat,No,early bird,Yes +LEC001,18,Computer Science,53703,27,153,mushroom,cat,No,early bird,Yes +LEC005,18,Data Science,53706,56.117017,-3.879547,pineapple,dog,Yes,night owl,Yes +LEC001,20,Engineering: Biomedical,53715,45.983964,9.262161,sausage,dog,No,night owl,No +LEC005,21,Psychology,53703,43.038902,-87.906471,macaroni/pasta,dog,Yes,night owl,Yes +LEC002,18,Engineering: Mechanical,53706,41.38879,2.15084,sausage,dog,Yes,no preference,Maybe +LEC003,18,Data Science,53706,47.48,-122.28,basil/spinach,dog,No,no preference,Maybe +LEC004,21,Data Science,53703,34.746613,113.625328,green pepper,neither,Yes,no preference,No +LEC005,21,Data Science,53703,38.240946,-85.757571,pepperoni,dog,No,no preference,Yes +LEC005,19,Engineering: Mechanical,53703,43.07291,-89.39439,sausage,dog,No,night owl,Maybe +LEC005,19,Engineering: Mechanical,53715,56.373482,-3.84306,none (just cheese),dog,No,early bird,Yes +LEC005,19,Data Science,53703,41.381717,2.177925,pepperoni,dog,Yes,night owl,Yes +LEC005,19,Engineering: Mechanical,53714,43.089199,87.8876,pepperoni,dog,No,night owl,Yes +LEC005,19,Engineering: Other,53590,38.4,11.2,pepperoni,dog,Yes,early bird,No +LEC005,19,Engineering: Mechanical,53715,25.761681,-80.191788,pepperoni,dog,Yes,night owl,No +LEC005,19,Engineering: Mechanical,53703,44.5133,88.0133,mushroom,dog,Yes,night owl,Maybe +LEC002,,Computer Science,53706,41.8781,87.6298,pepperoni,dog,No,night owl,Maybe +LEC005,19,Business: Finance,53703,38.98378,-77.20871,none (just cheese),dog,Yes,night owl,Yes +LEC005,18,Business: Finance,53703,22.9068,43.1729,pepperoni,dog,No,night owl,Yes +LEC005,19,Engineering: Mechanical,53715,43.073051,-89.40123,pepperoni,dog,No,early bird,No +LEC004,23,Economics,53703,43.083321,-89.372475,mushroom,dog,Yes,early bird,No +LEC002,17,Business: Actuarial,53715,34.746613,113.625328,sausage,neither,Yes,night owl,Maybe +LEC005,18,Engineering: Biomedical,53715,46.58276,7.08058,pepperoni,dog,No,early bird,No +LEC001,20,Statistics,53715,39.904202,116.407394,mushroom,dog,Yes,early bird,No +LEC002,18,Computer Science,53706,35.96691,-75.627823,sausage,dog,No,early bird,Yes +LEC005,21,Mathematics/AMEP,53703,13.756331,100.501762,pepperoni,dog,No,night owl,Yes +LEC005,20,Engineering: Biomedical,53715,28.538336,-81.379234,sausage,cat,No,night owl,Maybe +LEC002,19,Engineering: Mechanical,53703,44.822783,-93.370743,sausage,dog,Yes,early bird,No +LEC005,19,Engineering: Mechanical,53715,42.15,-87.96,pepperoni,dog,No,night owl,Yes +LEC005,20,Journalism,53715,41.3874,2.1686,basil/spinach,dog,Yes,early bird,Maybe +LEC001,19,Engineering: Mechanical,53703,42.864552,-88.333199,pepperoni,dog,No,early bird,Maybe +LEC005,17,Data Science,53706,40.7128,74.006,macaroni/pasta,dog,No,night owl,Yes +LEC005,19,Science: Other|Politcal Science,53703,41.878113,-87.629799,pepperoni,dog,Yes,night owl,No +LEC002,20,Business: Finance,53703,40.7831,73.9712,sausage,dog,Yes,night owl,No +LEC004,20,Data Science,53703,43,87.9,none (just cheese),dog,No,night owl,Yes +LEC001,18,Data Science,53706,38.900497,-77.007507,pineapple,dog,No,night owl,Maybe +LEC005,18,Engineering: Industrial,53706,45.440845,12.315515,sausage,dog,No,night owl,Maybe +LEC002,19,Data Science,53715,25.73403,-80.24697,pepperoni,dog,Yes,night owl,Yes +LEC005,18,Political Science,53706,42.360081,-71.058884,macaroni/pasta,dog,Yes,night owl,Yes +LEC002,20,Economics,53703,41.878113,-87.629799,pepperoni,dog,Yes,no preference,Maybe +LEC004,18,Engineering: Mechanical,55088,48.135124,11.581981,pepperoni,dog,Yes,no preference,No +LEC002,23,Business: Information Systems,53703,37.566536,126.977966,sausage,dog,No,night owl,Maybe +LEC005,17,Data Science,53703,49.2827,123.1207,sausage,dog,Yes,night owl,Yes +LEC005,,Statistics,53726,40.712776,-74.005974,Other,dog,Yes,no preference,Yes +LEC001,18,Science: Biology/Life,53706,48.856613,2.352222,pepperoni,cat,Yes,early bird,No +LEC005,32,Communication Sciences and Disorder,53705,37.566536,126.977966,pineapple,dog,Yes,no preference,Yes +LEC001,18,Data Science,53706,41.878113,-87.629799,macaroni/pasta,dog,No,night owl,Yes +LEC002,17,Business: Information Systems,53706,-6.17511,106.865036,sausage,neither,No,no preference,Maybe +LEC002,25,Science: Other|Geoscience,53711,46.947975,7.447447,mushroom,cat,No,no preference,Yes +LEC002,20,Economics,53703,46.7867,92.1005,macaroni/pasta,neither,Yes,early bird,No +LEC002,21,Business: Other|Marketing,53703,20.878332,-156.682495,basil/spinach,dog,No,night owl,Yes +LEC001,19,Statistics,53703,52.370216,4.895168,sausage,dog,No,night owl,Maybe +LEC005,20,Engineering: Biomedical,53711,35.689487,139.691711,basil/spinach,dog,No,night owl,Yes +LEC005,22,Science: Other|Atmospheric and oceanic science,53703,26.1224,80.1373,pepperoni,dog,No,early bird,No +LEC001,18,Engineering: Mechanical,53726,21.306944,-157.858337,sausage,dog,No,night owl,Yes +LEC005,21,Business: Finance,53703,43.11339,-89.37726,sausage,dog,No,night owl,Yes +LEC001,,Business: Other,53703,22.396427,114.109497,Other,dog,No,early bird,Maybe +LEC004,19,Science: Biology/Life,53706,41.2,96,pepperoni,cat,No,early bird,No +LEC004,18,Engineering: Industrial,53706,49.74609,7.4609,pepperoni,cat,No,early bird,Yes +LEC004,20,Science: Other|Environmental Science,53715,43,-89,mushroom,dog,Yes,night owl,Maybe +LEC001,18,Business: Finance,53706,39.7392,104.9903,pepperoni,dog,No,early bird,No +LEC002,,Computer Science,53706,41.67566,-86.28645,pineapple,cat,No,no preference,Maybe +LEC002,18,Business: Other,53706,33.88509,-118.409714,green pepper,dog,Yes,night owl,No +LEC001,20,Engineering: Biomedical,53711,41.8781,87.6298,pepperoni,dog,No,night owl,Yes +LEC002,20,Data Science,53715,10.97285,106.477707,mushroom,dog,No,no preference,Maybe +LEC002,20,Computer Science,53703,36.16156,-75.752441,pepperoni,dog,Yes,no preference,Yes +LEC002,20,Business: Other|Marketing,53703,35.689487,139.691711,pepperoni,dog,Yes,night owl,Yes +LEC002,18,Engineering: Other|Engineering Mechanics,53706,35.689487,139.691711,mushroom,cat,No,night owl,Maybe +LEC002,21,Economics (Mathematical Emphasis),53703,46.25872,-91.745583,sausage,dog,Yes,no preference,Yes +LEC002,19,Mathematics,53703,39.904202,116.407394,tater tots,cat,No,night owl,Yes +LEC002,18,Data Science,53703,40.706067,-74.030063,pepperoni,dog,No,night owl,Yes +LEC002,19,Pre-Business,53703,39.60502,-106.51641,pepperoni,dog,Yes,early bird,No +LEC002,20,Mathematics/AMEP,53703,35.106766,-106.629181,green pepper,cat,No,night owl,Yes +LEC003,20,Science: Physics,53715,64.963051,-19.020836,mushroom,dog,No,night owl,Yes +LEC002,20,Business: Finance,53703,31.298973,120.585289,pineapple,cat,Yes,night owl,No +LEC002,18,Economics,53706,48.856613,2.352222,basil/spinach,dog,No,night owl,Maybe +LEC001,21,Data Science,53703,40.712776,-74.005974,sausage,dog,No,night owl,Yes +LEC002,19,Engineering: Industrial,53715,45.914,-89.255,sausage,dog,Yes,early bird,Yes +LEC002,19,Computer Science,53703,20,110,pineapple,cat,No,night owl,Maybe +LEC002,19,Engineering: Mechanical,53726,41.878113,-87.629799,basil/spinach,dog,No,early bird,Yes +LEC005,19,Computer Science,53715,48.8566,2.3522,sausage,dog,No,night owl,Maybe +LEC002,19,Industrial Engineering,53703,48.856613,2.352222,basil/spinach,dog,No,early bird,Yes +LEC002,18,Data Science,53706,43.073051,-89.40123,pepperoni,dog,Yes,night owl,Yes +LEC002,20,Statistics,53703,31.224361,121.46917,mushroom,dog,No,no preference,Maybe +LEC002,18,Computer Science,53706,35.689487,139.691711,green pepper,dog,No,night owl,Yes +LEC002,18,Computer Science,53706,25.03841,121.563698,pineapple,dog,No,night owl,Yes +LEC002,19,Engineering: Mechanical,53715,43.06827,-89.40263,sausage,dog,No,night owl,No +LEC002,18,Engineering: Mechanical,53703,43,89.4,pepperoni,cat,No,no preference,Maybe +LEC002,,Mechanical Engineering,53703,41.8781,87.6298,Other,dog,Yes,night owl,Yes +LEC002,26,Science: Other,57075,42.76093,-89.9589,Other,dog,Yes,early bird,No +LEC002,21,Science: Other|Environmental science,53714,47.606209,-122.332069,pepperoni,dog,Yes,early bird,Yes +LEC002,18,Data Science,53706,35.69,139.69,pineapple,cat,No,night owl,Yes +LEC002,18,Computer Science,53706,42.807091,-86.01886,none (just cheese),cat,Yes,early bird,Yes +LEC002,19,Engineering: Mechanical,53703,45.892099,8.997803,green pepper,dog,No,night owl,Yes +LEC002,20,Computer Science,53715,40.755645,-74.034119,sausage,dog,Yes,night owl,Yes +LEC001,18,Engineering: Mechanical,53066,43.073051,-89.40123,pepperoni,dog,No,night owl,Yes +LEC002,18,Data Science,53706,21.306944,-157.858337,pineapple,dog,No,night owl,No +LEC002,18,Engineering: Industrial,53706,32.0853,34.781769,pepperoni,dog,No,night owl,Maybe +LEC002,19,Engineering: Mechanical,53703,46.786671,-92.100487,sausage,dog,No,early bird,No +LEC002,19,Engineering: Mechanical,53715,42.590519,-88.435287,pepperoni,dog,No,early bird,No +LEC002,23,Data Science,53703,37,127,pineapple,dog,No,night owl,Yes +LEC002,20,Data Science,53703,43.06875,-89.39434,pepperoni,dog,Yes,no preference,Maybe +LEC002,20,Engineering: Mechanical,53703,41.499321,-81.694359,pepperoni,dog,Yes,night owl,Maybe +LEC002,21,Economics,53703,38.969021,-0.18516,sausage,dog,Yes,no preference,No +LEC002,20,Economics,53703,50.85,4.35,pepperoni,dog,No,no preference,Yes +LEC002,19,Data Science,53715,36.39619,10.61412,none (just cheese),cat,No,no preference,Yes +LEC002,20,Engineering: Mechanical,53711,43.073051,-89.40123,green pepper,dog,Yes,night owl,No +LEC002,30,Life Sciences Communication,53562,52.399448,0.25979,basil/spinach,cat,Yes,night owl,Yes +LEC002,20,Business: Finance,53703,41.878,-87.629799,pepperoni,dog,No,no preference,Yes +LEC002,18,Computer Science,53706,31.2304,121.4737,pepperoni,cat,No,night owl,Maybe +LEC005,22,Economics,53711,48.135124,11.581981,pepperoni,cat,Yes,no preference,Yes +LEC002,19,Engineering: Mechanical,53711,51.5,0.1276,pepperoni,dog,No,night owl,No +LEC001,18,Computer Science,53703,31.298973,120.585289,pineapple,neither,No,night owl,No +LEC001,19,Computer Science,53703,37,-97,macaroni/pasta,cat,No,no preference,Maybe +LEC002,19,International Studies,53703,8.25115,34.588348,none (just cheese),dog,Yes,early bird,Maybe +LEC001,19,Engineering: Mechanical,53703,43.038902,-87.906471,pineapple,cat,No,night owl,Yes +LEC001,19,Science: Other|Atmospheric and Oceanic Sciences,53703,48.856613,2.352222,pepperoni,dog,Yes,night owl,Yes +LEC004,20,Data Science,53703,41.878113,-87.629799,green pepper,dog,No,early bird,Yes +LEC004,18,Undecided,53706,39.3823,87.2971,sausage,dog,Yes,early bird,No +LEC004,21,Data Science,53703,31.230391,121.473701,mushroom,cat,No,night owl,Maybe +LEC001,18,Data Science,53706,32.776474,-79.931053,none (just cheese),dog,No,early bird,Yes +LEC006,18,Science: Physics,53706,43.073051,-89.40123,sausage,dog,No,night owl,Yes +LEC001,19,Economics,53703,35.689487,139.691711,pineapple,dog,Yes,night owl,Yes +LEC004,18,Data Science,53715,50.8,-1.085,Other,dog,No,night owl,Maybe +LEC002,21,Languages,53703,37.389091,-5.984459,mushroom,cat,No,early bird,No +LEC001,19,Rehabilitation Psychology,53706,36.204823,138.25293,pineapple,cat,No,no preference,Maybe +LEC006,18,Data Science,53705,37.5741,122.3794,pepperoni,dog,Yes,night owl,Yes +LEC004,18,Undecided,53706,26.452,-81.9481,pepperoni,dog,Yes,night owl,Yes +LEC002,19,Business: Actuarial,53703,37.774929,-122.419418,pineapple,dog,No,early bird,No +LEC005,18,Undecided,53706,55.676098,12.568337,pepperoni,dog,Yes,night owl,No +LEC001,19,Engineering: Mechanical,53703,43.073051,-89.40123,pepperoni,dog,Yes,night owl,Yes +LEC002,18,Statistics,53706,40.713051,-74.007233,none (just cheese),dog,No,night owl,Maybe +LEC003,21,Languages,53511,39.952583,-75.165222,pepperoni,dog,No,night owl,Yes +LEC002,18,Computer Science,53706,12.523579,-70.03355,pineapple,dog,No,night owl,Yes +LEC004,,Engineering: Biomedical,53715,41.878113,-87.629799,pepperoni,dog,Yes,night owl,No +LEC001,,Data Science,53701,40.37336,88.231483,pepperoni,dog,Yes,night owl,No +LEC001,19,Data Science,53703,51.5072,0.1276,pepperoni,dog,Yes,no preference,No +LEC002,18,Data Science,53706,47.987289,0.22367,none (just cheese),dog,Yes,night owl,Maybe +LEC002,19,Business: Actuarial,53715,45.17963,-87.150009,sausage,dog,Yes,no preference,No +LEC005,21,Science: Biology/Life,53703,21.23556,-86.73142,pepperoni,dog,Yes,night owl,Yes +LEC004,18,Engineering: Industrial,53706,43.073051,-89.40123,sausage,dog,No,night owl,Yes +LEC001,21,Science: Biology/Life,53715,41.878113,-87.629799,green pepper,cat,No,night owl,Yes +LEC001,20,Engineering: Biomedical,53703,48.8566,2.3522,mushroom,cat,Yes,night owl,Maybe +LEC005,19,Engineering: Mechanical,53703,49.28273,-123.120735,basil/spinach,dog,No,night owl,Yes +LEC001,19,Data Science,53706,37.23082,-107.59529,basil/spinach,dog,No,no preference,Maybe +LEC001,19,Business: Finance,53703,26.20047,127.728577,mushroom,dog,No,night owl,Maybe +LEC006,18,Statistics,53706,32.060253,118.796875,pineapple,cat,Yes,early bird,Maybe +LEC002,20,Business: Information Systems,53706,52.520008,13.404954,none (just cheese),dog,No,early bird,Yes +LEC006,18,Undecided,53706,43.038902,-87.906471,sausage,dog,No,night owl,Yes +LEC002,20,Accounting,53703,32.79649,-117.192123,mushroom,dog,No,no preference,Yes +LEC006,19,Statistics,53715,21.315603,-157.858093,pepperoni,cat,No,night owl,No +LEC004,20,Science: Biology/Life,53706,13.756331,100.501762,pineapple,neither,No,night owl,Yes +LEC004,20,Business: Other,53715,42.818878,-89.494115,pepperoni,dog,No,night owl,Yes +LEC001,19,Engineering: Mechanical,53703,44.9778,93.265,pepperoni,dog,Yes,night owl,Maybe +LEC004,18,Engineering: Industrial,53706,41.3874,2.1686,none (just cheese),dog,No,night owl,Maybe +LEC001,37,Engineering: Other|Civil- Intelligent Transportation System,53705,23.810331,90.412521,pineapple,neither,Yes,early bird,Yes +LEC001,19,Science: Physics,53703,42.696842,-89.026932,sausage,cat,No,night owl,Yes +LEC006,19,Data Science,53715,53.266479,-9.052602,macaroni/pasta,dog,No,no preference,Yes +LEC001,19,Data Science,53703,45.19356,-87.118767,pepperoni,dog,Yes,early bird,Maybe +LEC005,18,Engineering: Industrial,53715,21.306944,-157.858337,none (just cheese),dog,Yes,night owl,Maybe +LEC004,19,Computer Science,53703,40.678177,-73.94416,Other,cat,No,night owl,Maybe +LEC005,18,Science: Biology/Life,53706,44.513317,-88.013298,pepperoni,dog,Yes,night owl,No +LEC001,19,Engineering: Mechanical,53703,40.712776,-74.005974,none (just cheese),dog,Yes,early bird,Maybe +LEC002,22,Economics,53703,37.6,127,pineapple,neither,Yes,night owl,Maybe +LEC004,20,Engineering: Industrial,53703,39.359772,-111.584167,pepperoni,dog,Yes,early bird,Maybe +LEC001,19,Data Science,53706,31.298973,120.585289,mushroom,cat,No,night owl,Yes +LEC001,20,Computer Science,53715,43.073051,-89.40123,none (just cheese),dog,No,night owl,Maybe +LEC001,25,Data Science,53703,37.566536,126.977966,pineapple,dog,Yes,night owl,No +LEC005,19,Data Science,53706,36.169941,-115.139832,pepperoni,dog,Yes,night owl,Yes +LEC001,19,Engineering: Mechanical,53703,44.834209,87.376266,sausage,dog,Yes,no preference,Yes +LEC005,20,Engineering: Mechanical,53703,43.17854,-89.163391,sausage,dog,Yes,night owl,Maybe +LEC004,19,Engineering: Industrial,53703,41.93101,-87.64987,pepperoni,neither,No,early bird,No +LEC003,19,Engineering: Industrial,53703,11.89,-85,pepperoni,dog,Yes,night owl,Maybe +LEC003,19,Engineering: Mechanical,53715,33.873417,-115.900993,pepperoni,dog,No,early bird,No +LEC001,22,Economics,53703,42.360081,-71.058884,pepperoni,dog,No,no preference,Maybe +LEC001,18,Data Science,53706,34.04018,-118.48849,pepperoni,dog,Yes,night owl,Yes +LEC002,42069,Data Science,53704,43,-89,none (just cheese),neither,No,no preference,No +LEC004,20,Business: Finance,53715,38.71049,-75.07657,sausage,dog,No,early bird,No +LEC004,21,Engineering: Mechanical,53715,43.073051,-89.40123,Other,dog,Yes,early bird,No +LEC004,18,Engineering: Industrial,53706,44.261799,-88.407249,sausage,dog,Yes,night owl,No +LEC004,26,Science: Other|Animal and Dairy Science,53705,53.270668,-9.05679,pepperoni,dog,No,early bird,Yes +LEC005,20,Data Science,53715,43.355099,11.02956,sausage,dog,No,early bird,Maybe +LEC003,19,Engineering: Mechanical,53715,45.40857,-91.73542,sausage,dog,Yes,no preference,No +LEC004,22,Engineering: Mechanical,53726,55.864239,-4.251806,pepperoni,dog,Yes,night owl,Yes +LEC001,18,Engineering: Mechanical,53706,50.808712,-0.1604,pepperoni,dog,Yes,night owl,Maybe +LEC004,19,Engineering: Mechanical,53703,13.35433,103.77549,none (just cheese),dog,No,no preference,Maybe +LEC005,24,Mathematics/AMEP,53705,40.7,-74,pineapple,cat,No,early bird,Maybe +LEC001,19,Interior Architecture,53532,27.683536,-82.736092,mushroom,cat,Yes,no preference,Yes +LEC001,19,Science: Chemistry,53715,40.7,-74,sausage,dog,No,night owl,Maybe +LEC001,20,Engineering: Biomedical,53703,-33.86882,151.20929,pepperoni,dog,No,no preference,Maybe +LEC001,20,Engineering: Industrial,53715,26.614149,-81.825768,pepperoni,dog,No,night owl,No +LEC001,19,Engineering: Biomedical,53706,45.440845,12.315515,none (just cheese),dog,Yes,night owl,Yes +LEC001,19,Data Science,53726,43.0766,89.4125,none (just cheese),cat,No,night owl,No +LEC001,20,Engineering: Biomedical,53711,33.684566,-117.826508,pineapple,dog,Yes,early bird,Maybe +LEC001,21,Statistics,26617,22.396427,114.109497,pineapple,dog,Yes,night owl,Maybe +LEC001,18,Data Science,53706,-33.86882,151.20929,pepperoni,dog,Yes,night owl,No +LEC001,21,Economics,53703,1.53897,103.58007,pineapple,neither,Yes,night owl,Yes +LEC001,18,Data Science,53558,41.877541,-88.066727,mushroom,dog,No,night owl,Maybe +LEC001,17,Computer Science,53703,25.204849,55.270782,pepperoni,dog,Yes,night owl,Yes +LEC001,19,Engineering: Mechanical,53715,19.7,-155,pineapple,dog,Yes,early bird,Yes +LEC001,19,Data Science,53703,41.878113,-87.629799,none (just cheese),cat,Yes,night owl,Yes +LEC001,18,Science: Biology/Life,53715,39.904202,116.407394,basil/spinach,dog,Yes,night owl,Maybe +LEC001,20,Science: Physics,53711,43.038902,-87.906471,pepperoni,dog,No,no preference,Yes +LEC001,18,Engineering: Mechanical,53706,41.902782,12.496366,pepperoni,neither,Yes,night owl,Yes +LEC001,18,Data Science,53706,47.60323,-122.330276,Other,dog,No,night owl,Yes +LEC001,19,Economics,53706,40.7,74,none (just cheese),dog,Yes,night owl,Yes +LEC001,19,Business: Finance,53703,34.052235,-118.243683,mushroom,dog,Yes,early bird,Maybe +LEC001,20,Science: Other|Atmospheric & Oceanic Sciences,53711,40.412776,-74.005974,pepperoni,neither,No,early bird,Yes +LEC001,19,Computer Science,53706,37.774929,-122.419418,none (just cheese),cat,No,early bird,Yes +LEC001,20,Engineering: Mechanical,53703,44.78441,-93.17308,pepperoni,dog,Yes,no preference,Yes +LEC001,22,Engineering: Other,53726,39.48214,-106.048691,pineapple,cat,No,no preference,Maybe +LEC001,21,Computer Science,53703,33.68,-117.82,basil/spinach,cat,No,early bird,No +LEC001,17,Computer Science,53706,25.204849,55.270782,pepperoni,neither,Yes,no preference,Maybe +LEC001,18,Engineering: Industrial,53706,41.917519,-87.694771,basil/spinach,dog,Yes,night owl,Yes +LEC001,18,Engineering: Biomedical,53706,42.361145,-71.057083,macaroni/pasta,dog,No,night owl,Yes +LEC001,,Engineering: Biomedical,53703,43.073929,-89.385239,basil/spinach,dog,No,early bird,No +LEC001,18,Economics,53706,30.20241,120.226822,Other,neither,Yes,early bird,No +LEC001,20,Engineering: Biomedical,53703,41.198496,0.773436,pepperoni,dog,No,night owl,Yes +LEC001,19,Engineering: Mechanical,53703,39.739235,-104.99025,pepperoni,dog,Yes,no preference,Maybe +LEC001,20,Science: Chemistry,53703,32.16761,120.012444,pepperoni,neither,No,night owl,Maybe +LEC001,19,Data Science,53703,43.0722,89.4008,pineapple,dog,Yes,night owl,Yes +LEC001,18,Science: Biology/Life,53715,41.878113,-87.629799,sausage,dog,Yes,early bird,No +LEC004,,Business: Information Systems,53715,42.360081,-71.058884,Other,dog,No,no preference,Maybe +LEC001,21,Engineering: Biomedical,53703,44.513317,-88.013298,pepperoni,dog,No,night owl,No +LEC001,20,Data Science,53132,43.073051,-89.40123,Other,cat,No,night owl,Maybe +LEC001,18,Business: Actuarial,53706,48.856613,2.352222,sausage,dog,No,no preference,Maybe +LEC001,20,Political Science,53715,48.135124,11.581981,sausage,cat,Yes,night owl,Yes +LEC001,19,Engineering: Industrial,53703,41,-74,sausage,dog,Yes,no preference,No +LEC001,20,Psychology,53703,43.083321,-89.372475,Other,neither,No,night owl,Yes +LEC001,18,Computer Science and Statistics,53706,36.162663,-86.781601,mushroom,dog,Yes,early bird,Maybe +LEC001,19,Engineering: Mechanical,53703,25.88,-80.16,pepperoni,dog,No,night owl,Yes +LEC001,18,Computer Science,53703,46.947975,7.447447,sausage,cat,Yes,night owl,No +LEC001,19,Business: Information Systems,53703,41.17555,73.64731,pepperoni,dog,No,night owl,Maybe +LEC001,20,Political Science,53703,45.018269,-93.473892,sausage,dog,No,night owl,Maybe +LEC001,,Business analytics,53705,45.50169,-73.567253,pineapple,cat,No,no preference,No +LEC001,21,Science: Biology/Life,53726,32.060253,118.796875,mushroom,cat,No,night owl,No +LEC001,19,Engineering: Mechanical,53706,35.806,-78.68483,none (just cheese),dog,No,night owl,Yes +LEC005,20,Data Science,53726,31.230391,121.473701,none (just cheese),dog,Yes,no preference,Maybe +LEC005,18,Engineering: Mechanical,53706,41.878113,-87.629799,Other,cat,No,night owl,Maybe +LEC004,18,Statistics,53706,27.35741,-82.615471,none (just cheese),dog,Yes,early bird,No +LEC002,20,Business: Finance,53715,35.726212,-83.491226,pepperoni,dog,Yes,no preference,Yes +LEC002,18,Undecided,53706,43.769562,11.255814,pepperoni,dog,No,night owl,Yes +LEC004,19,Business: Actuarial,53703,43.040433,-87.897423,sausage,cat,No,night owl,No +LEC004,19,Engineering: Mechanical,5,25.034281,-77.396278,sausage,dog,Yes,no preference,Yes +LEC001,,Engineering: Mechanical,53706,34.052235,-118.243683,Other,dog,Yes,night owl,Yes +LEC003,18,Engineering: Industrial,53706,20.798363,-156.331924,none (just cheese),dog,Yes,early bird,No +LEC002,19,Engineering: Biomedical,53703,51.1784,115.5708,pineapple,dog,Yes,night owl,No +LEC005,19,Statistics,53703,43.05367,-88.44062,pepperoni,dog,Yes,night owl,No +LEC004,18,Engineering: Industrial,53706,36.110168,-97.058571,none (just cheese),dog,No,early bird,Maybe +LEC004,21,Computer Science,53703,43.07016,-89.39386,mushroom,cat,Yes,early bird,No +LEC005,19,Data Science,53726,43.073051,-89.40123,pepperoni,dog,No,early bird,Yes +LEC004,18,Data Science,53706,41.878113,-87.629799,macaroni/pasta,dog,Yes,early bird,Maybe +LEC001,20,Business: Finance,53726,43.073051,-89.40123,pepperoni,dog,No,night owl,Maybe +LEC001,18,Data Science,53706,43.038902,-87.906471,pineapple,dog,No,night owl,Maybe +LEC001,24,Engineering: Other,53718,46.77954,-90.78511,pineapple,dog,Yes,night owl,No +LEC001,18,Statistics,53706,22.57,88.36,pineapple,dog,Yes,night owl,Maybe +LEC004,20,Computer Science,53715,35.016956,-224.24911,pepperoni,dog,No,night owl,Yes +LEC001,20,Science: Biology/Life,53715,47.606209,-122.332069,none (just cheese),dog,Yes,night owl,Maybe +LEC004,18,Engineering: Industrial,53706,21.28482,-157.83245,pineapple,dog,No,night owl,Yes +LEC001,20,Engineering: Biomedical,53715,40.63,14.6,none (just cheese),dog,No,early bird,Maybe +LEC004,20,Legal Studies,53703,20.798363,-156.331924,green pepper,dog,No,early bird,No +LEC002,18,Computer Science,53706,32.060253,118.796875,sausage,dog,Yes,early bird,Maybe +LEC002,18,Journalism,53706,31,103,none (just cheese),cat,No,night owl,Yes +LEC004,,Computer Science,53706,147,32.5,pineapple,cat,No,early bird,Maybe +LEC004,18,Engineering: Biomedical,53701,43.038902,-87.906471,pepperoni,dog,No,night owl,No +LEC004,18,Engineering: Mechanical,20815,39.640259,-106.370872,sausage,dog,No,night owl,No +LEC004,19,Engineering: Mechanical,53715,41,12,pepperoni,dog,No,no preference,Maybe +LEC004,20,Journalism: Strategic Comm./Advertising,53703,43.073051,-89.40123,Other,dog,Yes,night owl,Yes +LEC004,,Engineering: Mechanical,53715,43,-87.9,pepperoni,cat,Yes,early bird,Maybe +LEC004,19,Engineering: Biomedical,53706,32.715736,117.161087,pepperoni,dog,Yes,no preference,Yes +LEC004,18,Data Science,53706,43.073051,-89.40123,pepperoni,dog,No,night owl,Yes +LEC004,18,History,53706,42.19381,-73.362877,none (just cheese),cat,Yes,night owl,Yes +LEC002,19,Engineering: Mechanical,53703,39.290386,-76.61219,mushroom,dog,No,no preference,No +LEC002,19,Engineering: Mechanical,53726,40.416775,-3.70379,macaroni/pasta,dog,No,early bird,Maybe +LEC005,19,Engineering: Mechanical,53726,46.870899,-89.313789,sausage,dog,Yes,night owl,Maybe +LEC004,19,Science: Biology/Life,53151,41.878113,-87.629799,sausage,dog,No,night owl,Yes +LEC005,18,Data Science,53711,35.1796,129.0756,pepperoni,cat,Yes,night owl,Yes +LEC004,18,Data Science,53706,37.568291,126.99778,pepperoni,dog,No,no preference,Maybe +LEC005,17,Statistics,53706,31.23,121.47,sausage,cat,No,night owl,Maybe +LEC003,19,Undecided,53715,43.041069,-87.909416,mushroom,dog,No,no preference,Maybe +LEC005,19,Economics,53703,47.606209,-122.332069,pineapple,neither,No,no preference,Maybe +LEC005,21,Science: Biology/Life,53726,40.76078,-111.891045,mushroom,dog,No,no preference,Yes +LEC003,19,Engineering: Mechanical,53706,43,-88.27,Other,dog,No,night owl,Yes +LEC003,20,Business: Other|Accounting,53726,43,-89,pepperoni,dog,Yes,early bird,Yes +LEC005,18,Engineering: Other,53706,64.147209,-21.9424,pepperoni,dog,No,night owl,Yes +LEC003,18,Data Science,53562,42.66544,21.165319,pepperoni,dog,No,night owl,Yes +LEC005,22,Data Science,53711,39.738449,-104.984848,none (just cheese),dog,No,night owl,Yes +LEC003,18,Engineering: Mechanical,53706,33.748997,-84.387985,mushroom,dog,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53717,41.2224,86.413,Other,dog,Yes,early bird,Maybe +LEC003,19,Business: Actuarial,53706,39.299236,-76.609383,pineapple,dog,Yes,night owl,No +LEC001,,Engineering: Mechanical,53703,32.776665,-96.796989,sausage,dog,No,night owl,Maybe +LEC004,19,Engineering: Biomedical,53703,41.878113,-87.629799,pepperoni,dog,Yes,no preference,Yes +LEC004,26,Master of Public Affairs,53715,48.118145,-123.43074,basil/spinach,dog,Yes,early bird,Yes +LEC004,19,Engineering: Mechanical,53703,-12.12168,-45.013481,basil/spinach,dog,No,night owl,Yes +LEC004,18,Data Science,53706,31.230391,121.473701,sausage,cat,No,night owl,No +LEC005,21,Engineering: Industrial,53715,1.352083,103.819839,none (just cheese),neither,No,night owl,Yes +LEC004,19,Engineering: Mechanical,53703,40.712776,-74.005974,sausage,dog,No,early bird,No +LEC004,19,Engineering: Mechanical,53715,37.98381,23.727539,basil/spinach,dog,Yes,early bird,No +LEC005,20,Business: Actuarial,53703,45.003288,-90.329788,sausage,dog,No,early bird,Maybe +LEC005,20,Engineering: Mechanical,53703,43.073051,-89.40123,pepperoni,dog,Yes,early bird,No +LEC001,21,Economics,53703,41.902782,12.496365,basil/spinach,dog,No,no preference,No +LEC004,18,Engineering: Biomedical,53706,45.4894,93.2476,mushroom,cat,No,night owl,No +LEC005,19,Data Science,53703,43.2708,89.7221,sausage,dog,Yes,night owl,No +LEC003,,Engineering: Mechanical,53706,45.87128,-89.711632,pepperoni,neither,Yes,no preference,Yes +LEC004,19,Engineering: Mechanical,53715,42.360081,-71.058884,pepperoni,dog,Yes,night owl,Maybe +LEC004,18,Engineering: Mechanical,53706,45.056389,-92.960793,pepperoni,dog,No,night owl,Yes +LEC003,,Computer Science,53703,43.07,-89.4,pepperoni,dog,Yes,no preference,Maybe +LEC001,20,Business: Finance,53703,22.20315,-159.495651,Other,dog,Yes,no preference,No +LEC005,19,Engineering: Mechanical,53703,44.74931,-92.80088,pineapple,dog,No,early bird,No +LEC004,21,Business: Actuarial,53726,38.874341,-77.032013,pepperoni,dog,No,no preference,Yes +LEC005,19,Engineering: Mechanical,53703,18.34791,-64.71424,basil/spinach,dog,No,night owl,No +LEC004,18,Engineering: Mechanical,53703,27.5041,82.7145,sausage,dog,No,night owl,Maybe +LEC005,19,Engineering: Biomedical,53706,36.462,25.375465,basil/spinach,dog,No,night owl,No +LEC004,27,Environment & Resources,53703,37.389091,-5.984459,mushroom,dog,No,night owl,Maybe +LEC004,19,Business: Actuarial,53726,32,-117,pepperoni,neither,Yes,night owl,Yes +LEC005,20,Science: Physics,53703,46.2833,-89.73,pepperoni,dog,No,early bird,Maybe +LEC003,19,Engineering: Industrial,53703,40.712776,-74.005974,basil/spinach,dog,Yes,night owl,No +LEC003,18,Data Science,53706,40.712776,-74.005974,Other,dog,Yes,early bird,No +LEC005,,Data Science,53703,43.073051,-89.40123,pepperoni,dog,No,night owl,No +LEC004,21,Business: Actuarial,53703,39.19067,-106.819199,macaroni/pasta,cat,No,no preference,Maybe +LEC006,18,Engineering: Industrial,53706,37.743042,-122.415642,green pepper,dog,Yes,no preference,No +LEC003,20,Economics,53703,22.54,114.05,pineapple,dog,No,night owl,Yes +LEC006,18,Data Science,53706,59.93428,30.335098,pineapple,dog,Yes,night owl,Maybe +LEC004,19,Engineering: Mechanical,53715,45.10994,-87.209793,pepperoni,dog,Yes,early bird,No +LEC002,20,Science: Biology/Life,53703,51.507351,-0.127758,pepperoni,dog,Yes,no preference,Yes +LEC004,18,Environmental Studies,53703,42.360081,-71.058884,pineapple,cat,No,no preference,Maybe +LEC004,19,Engineering: Mechanical,53715,45,-87,sausage,cat,Yes,no preference,Maybe +LEC004,19,Engineering: Mechanical,53703,48.137,11.575,pepperoni,dog,Yes,night owl,Maybe +LEC004,20,Engineering: Industrial,53711,48.856613,2.352222,sausage,cat,No,no preference,No +LEC004,18,Science: Other,53706,48.410648,-114.338188,none (just cheese),dog,No,no preference,Maybe +LEC004,18,Mathematics/AMEP,53706,24.585445,73.712479,pineapple,dog,Yes,night owl,Maybe +LEC003,18,Data Science,53706,36.974117,-122.030792,pepperoni,cat,Yes,night owl,Yes +LEC004,19,Computer Science,53715,40.79254,-98.70807,pepperoni,dog,Yes,night owl,No +LEC005,19,Engineering: Mechanical,53711,30.572815,104.066803,pineapple,dog,No,night owl,Yes +LEC001,21,Science: Chemistry,53715,3.139003,101.686852,pepperoni,neither,No,no preference,Maybe +LEC006,18,Data Science,53706,40.46,-90.67,sausage,dog,No,night owl,No +LEC004,20,Science: Other|Environmental Science,53715,43.073051,-89.40123,sausage,dog,No,night owl,Yes +LEC004,20,Engineering: Biomedical,53715,30.328227,-86.136975,pepperoni,dog,Yes,no preference,Maybe +LEC004,21,Science: Biology/Life,53703,41.385063,2.173404,macaroni/pasta,dog,No,night owl,Yes +LEC003,18,Mathematics/AMEP,53706,42.99571,-90,sausage,dog,Yes,night owl,Yes +LEC004,19,Engineering: Mechanical,53703,41.385063,2.173404,sausage,dog,Yes,night owl,Yes +LEC001,,Engineering: Industrial,53706,40.7128,74.006,pepperoni,dog,No,early bird,Yes +LEC005,18,Psychology,53706,9.167414,77.876747,mushroom,cat,No,early bird,No +LEC003,19,Engineering: Industrial,53715,24.713552,46.675297,basil/spinach,neither,Yes,early bird,Maybe +LEC001,18,Undecided,53706,44.8341,87.377,basil/spinach,dog,No,no preference,Yes +LEC003,19,Engineering: Mechanical,53705,46.589146,-112.039108,none (just cheese),cat,No,night owl,Yes +LEC001,20,Economics,53703,39.631506,118.143239,pineapple,dog,No,night owl,Maybe \ No newline at end of file diff --git a/f22/meena_lec_notes/lec-24/lec_24_comprehensions.ipynb b/f22/meena_lec_notes/lec-24/lec_24_comprehensions.ipynb index b6390a5..2776fa4 100644 --- a/f22/meena_lec_notes/lec-24/lec_24_comprehensions.ipynb +++ b/f22/meena_lec_notes/lec-24/lec_24_comprehensions.ipynb @@ -22,8 +22,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Review of lambdas\n", - "- lambda functions are a way to abstract a function reference\n", + "### Using `lambda`\n", + "- `lambda` functions are a way to abstract a function reference\n", "- lambdas are simple functions with:\n", " - multiple possible parameters\n", " - single expression line as the function body\n", @@ -31,7 +31,10 @@ " - mathematical functions\n", " - lookup operations\n", "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* parameters: expression" + "- Syntax: \n", + "```python \n", + "lambda parameters: expression\n", + "```" ] }, { @@ -982,11 +985,12 @@ "text/plain": [ "['Lecture',\n", " 'Age',\n", - " 'Primary major',\n", - " 'Other majors',\n", + " 'Major',\n", " 'Zip Code',\n", + " 'Latitude',\n", + " 'Longitude',\n", " 'Pizza topping',\n", - " 'Pet owner',\n", + " 'Pet preference',\n", " 'Runner',\n", " 'Sleep habit',\n", " 'Procrastinator']" @@ -1026,13 +1030,22 @@ " col_idx = cs220_header.index(col_name) \n", " val = cs220_data[row_idx][col_idx] \n", " \n", - " # handle missing values, by returning None\n", + " # handle missing values\n", " if val == '':\n", " return None\n", " \n", " # handle type conversions\n", - " if col_name in [\"Age\",]:\n", + " if col_name == \"Age\":\n", + " val = int(val)\n", + " if 0 < val <= 118:\n", + " return val\n", + " else:\n", + " # Data cleaning\n", + " return None\n", + " elif col_name in ['Zip Code',]:\n", " return int(val)\n", + " elif col_name in ['Latitude', 'Longitude']:\n", + " return float(val)\n", " \n", " return val" ] @@ -1045,26 +1058,28 @@ { "data": { "text/plain": [ - "[{'Lecture': 'LEC002',\n", - " 'Age': 19,\n", - " 'Primary major': 'Engineering: Mechanical',\n", - " 'Other majors': '',\n", - " 'Zip Code': '53711',\n", - " 'Pizza topping': 'pepperoni',\n", - " 'Pet owner': 'Yes',\n", + "[{'Lecture': 'LEC001',\n", + " 'Age': 22,\n", + " 'Major': 'Engineering: Biomedical',\n", + " 'Zip Code': 53703,\n", + " 'Latitude': 43.073051,\n", + " 'Longitude': -89.40123,\n", + " 'Pizza topping': 'none (just cheese)',\n", + " 'Pet preference': 'neither',\n", " 'Runner': 'No',\n", - " 'Sleep habit': 'night owl',\n", + " 'Sleep habit': 'no preference',\n", " 'Procrastinator': 'Maybe'},\n", - " {'Lecture': 'LEC002',\n", - " 'Age': 20,\n", - " 'Primary major': 'Science: Physics',\n", - " 'Other majors': 'Astronomy-Physics, History',\n", - " 'Zip Code': '53726',\n", - " 'Pizza topping': 'pineapple',\n", - " 'Pet owner': 'Yes',\n", - " 'Runner': 'Yes',\n", - " 'Sleep habit': 'night owl',\n", - " 'Procrastinator': 'Yes'}]" + " {'Lecture': 'LEC006',\n", + " 'Age': None,\n", + " 'Major': 'Undecided',\n", + " 'Zip Code': 53706,\n", + " 'Latitude': 43.073051,\n", + " 'Longitude': -89.40123,\n", + " 'Pizza topping': 'none (just cheese)',\n", + " 'Pet preference': 'neither',\n", + " 'Runner': 'No',\n", + " 'Sleep habit': 'no preference',\n", + " 'Procrastinator': 'Maybe'}]" ] }, "execution_count": 32, @@ -1079,18 +1094,14 @@ " \"\"\"\n", " #should be defined outside the for loop, because it stores the entire data\n", " dict_list = [] \n", - " for row in data:\n", + " for row_idx in range(len(data)):\n", + " row = data[row_idx]\n", " #should be defined inside the for loop, because it represents one row as a \n", " #dictionary\n", " new_row = {} \n", " for i in range(len(header)):\n", - " if header[i] == \"Age\":\n", - " if row[i] == '':\n", - " new_row[header[i]] = None\n", - " else:\n", - " new_row[header[i]] = int(row[i])\n", - " else:\n", - " new_row[header[i]] = row[i]\n", + " val = cell(row_idx, header[i])\n", + " new_row[header[i]] = val\n", " dict_list.append(new_row)\n", " return dict_list\n", " \n", @@ -1137,7 +1148,7 @@ { "data": { "text/plain": [ - "19.93" + "20.05" ] }, "execution_count": 34, @@ -1168,7 +1179,7 @@ { "data": { "text/plain": [ - "20.39" + "20.86" ] }, "execution_count": 35, @@ -1198,7 +1209,28 @@ { "data": { "text/plain": [ - "['no preference', 'night owl']" + "['night owl',\n", + " 'early bird',\n", + " 'no preference',\n", + " 'night owl',\n", + " 'no preference',\n", + " 'night owl',\n", + " 'night owl',\n", + " 'early bird',\n", + " 'early bird',\n", + " 'night owl',\n", + " 'early bird',\n", + " 'night owl',\n", + " 'night owl',\n", + " 'early bird',\n", + " 'night owl',\n", + " 'night owl',\n", + " 'night owl',\n", + " 'night owl',\n", + " 'no preference',\n", + " 'night owl',\n", + " 'no preference',\n", + " 'night owl']" ] }, "execution_count": 36, @@ -1239,7 +1271,12 @@ { "data": { "text/plain": [ - "{'LEC002': 161, 'LEC001': 239, 'LEC004': 129, 'LEC003': 191}" + "{'LEC001': 195,\n", + " 'LEC006': 78,\n", + " 'LEC004': 196,\n", + " 'LEC005': 190,\n", + " 'LEC002': 197,\n", + " 'LEC003': 136}" ] }, "execution_count": 37, @@ -1260,7 +1297,12 @@ { "data": { "text/plain": [ - "{'LEC002': 161, 'LEC001': 239, 'LEC004': 129, 'LEC003': 191}" + "{'LEC001': 195,\n", + " 'LEC006': 78,\n", + " 'LEC004': 196,\n", + " 'LEC005': 190,\n", + " 'LEC002': 197,\n", + " 'LEC003': 136}" ] }, "execution_count": 38, @@ -1289,18 +1331,18 @@ "data": { "text/plain": [ "['No',\n", - " 'Yes',\n", " 'No',\n", - " 'Yes',\n", " 'No',\n", " 'Yes',\n", " 'No',\n", " 'Yes',\n", " 'No',\n", + " 'No',\n", " 'Yes',\n", " 'No',\n", " 'No',\n", - " 'Yes',\n", + " 'No',\n", + " 'No',\n", " 'No',\n", " 'No']" ] @@ -1317,6 +1359,17 @@ " key = lambda s_dict: s_dict[\"Age\"], reverse = True)[:15]]" ] }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [], + "source": [ + "students_with_age = [student_dict for student_dict in transformed_data \\\n", + " if student_dict[\"Age\"] != None and 0 < student_dict[\"Age\"] <= 118]\n", + "#students_with_age" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1326,14 +1379,14 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'LEC002': 19.0, 'LEC001': 19, 'LEC004': 19.0, 'LEC003': 19}\n" + "{'LEC001': 19, 'LEC006': 18.0, 'LEC004': 19, 'LEC005': 19.0, 'LEC002': 19, 'LEC003': 19.0}\n" ] } ], @@ -1360,16 +1413,21 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'LEC002': 19.0, 'LEC001': 19, 'LEC004': 19.0, 'LEC003': 19}" + "{'LEC001': 19,\n", + " 'LEC006': 18.0,\n", + " 'LEC004': 19,\n", + " 'LEC005': 19.0,\n", + " 'LEC002': 19,\n", + " 'LEC003': 19.0}" ] }, - "execution_count": 41, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1390,16 +1448,21 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'LEC002': 28, 'LEC001': 36, 'LEC004': 23, 'LEC003': 27}" + "{'LEC001': 37,\n", + " 'LEC006': 23,\n", + " 'LEC004': 53,\n", + " 'LEC005': 32,\n", + " 'LEC002': 31,\n", + " 'LEC003': 25}" ] }, - "execution_count": 42, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1427,7 +1490,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -1436,7 +1499,7 @@ "[1936, 1089, 3136, 441, 361]" ] }, - "execution_count": 43, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1456,7 +1519,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 45, "metadata": {}, "outputs": [ { @@ -1465,7 +1528,7 @@ "[23.33, 51.288, 76.122, 17.2, 10.5]" ] }, - "execution_count": 44, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1485,7 +1548,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -1494,7 +1557,7 @@ "[2, 4, 8, 6, 4, 6, 2, 7]" ] }, - "execution_count": 45, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1514,7 +1577,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -1523,7 +1586,7 @@ "{'Bob': 5, 'Cindy': 11, 'Alice': 16, 'Meena': 3}" ] }, - "execution_count": 46, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1539,7 +1602,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -1548,7 +1611,7 @@ "{'Bob': 47.8, 'Cindy': 50.6, 'Alice': 54.0, 'Meena': 39.8}" ] }, - "execution_count": 47, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1575,30 +1638,34 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{17: 2,\n", - " 18: 180,\n", - " 19: 226,\n", - " 20: 144,\n", - " 21: 89,\n", - " 22: 25,\n", - " 23: 15,\n", - " 24: 10,\n", - " 25: 4,\n", - " 26: 2,\n", - " 27: 5,\n", + "{17: 22,\n", + " 18: 276,\n", + " 19: 275,\n", + " 20: 164,\n", + " 21: 103,\n", + " 22: 32,\n", + " 23: 14,\n", + " 24: 13,\n", + " 25: 10,\n", + " 26: 7,\n", + " 27: 1,\n", " 28: 1,\n", - " 30: 1,\n", + " 29: 2,\n", + " 30: 2,\n", " 31: 1,\n", - " 36: 1}" + " 32: 2,\n", + " 37: 2,\n", + " 41: 1,\n", + " 53: 1}" ] }, - "execution_count": 48, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -1618,30 +1685,30 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['Yes',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'No',\n", - " 'No',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'Yes',\n", - " 'No',\n", - " 'Yes',\n", - " 'Yes']" + "['dog',\n", + " 'dog',\n", + " 'neither',\n", + " 'dog',\n", + " 'dog',\n", + " 'dog',\n", + " 'dog',\n", + " 'neither',\n", + " 'dog',\n", + " 'dog',\n", + " 'dog',\n", + " 'cat',\n", + " 'dog',\n", + " 'dog',\n", + " 'dog']" ] }, - "execution_count": 49, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } @@ -1649,7 +1716,7 @@ "source": [ "students_with_age = [student_dict for student_dict in transformed_data \\\n", " if student_dict[\"Age\"] != None]\n", - "[student_dict[\"Pet owner\"] for student_dict in sorted(students_with_age, \\\n", + "[student_dict[\"Pet preference\"] for student_dict in sorted(students_with_age, \\\n", " key = lambda s_dict: s_dict[\"Age\"])[:15]]" ] } @@ -1670,7 +1737,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/f22/meena_lec_notes/lec-24/lec_24_comprehensions_template.ipynb b/f22/meena_lec_notes/lec-24/lec_24_comprehensions_template.ipynb index cad6868..f99460e 100644 --- a/f22/meena_lec_notes/lec-24/lec_24_comprehensions_template.ipynb +++ b/f22/meena_lec_notes/lec-24/lec_24_comprehensions_template.ipynb @@ -22,8 +22,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Review of lambdas\n", - "- lambda functions are a way to abstract a function reference\n", + "### Using `lambda`\n", + "- `lambda` functions are a way to abstract a function reference\n", "- lambdas are simple functions with:\n", " - multiple possible parameters\n", " - single expression line as the function body\n", @@ -31,7 +31,10 @@ " - mathematical functions\n", " - lookup operations\n", "- lambdas are often associated with a collection of values within a list\n", - "- Syntax: *lambda* parameters: expression" + "- Syntax: \n", + "```python \n", + "lambda parameters: expression\n", + "```" ] }, { @@ -672,13 +675,22 @@ " col_idx = cs220_header.index(col_name) \n", " val = cs220_data[row_idx][col_idx] \n", " \n", - " # handle missing values, by returning None\n", + " # handle missing values\n", " if val == '':\n", " return None\n", " \n", " # handle type conversions\n", - " if col_name in [\"Age\",]:\n", + " if col_name == \"Age\":\n", + " val = int(val)\n", + " if 0 < val <= 118:\n", + " return val\n", + " else:\n", + " # Data cleaning\n", + " return None\n", + " elif col_name in ['Zip Code',]:\n", " return int(val)\n", + " elif col_name in ['Latitude', 'Longitude']:\n", + " return float(val)\n", " \n", " return val" ] @@ -695,18 +707,14 @@ " \"\"\"\n", " #should be defined outside the for loop, because it stores the entire data\n", " dict_list = [] \n", - " for row in data:\n", + " for row_idx in range(len(data)):\n", + " row = data[row_idx]\n", " #should be defined inside the for loop, because it represents one row as a \n", " #dictionary\n", " new_row = {} \n", " for i in range(len(header)):\n", - " if header[i] == \"Age\":\n", - " if row[i] == '':\n", - " new_row[header[i]] = None\n", - " else:\n", - " new_row[header[i]] = int(row[i])\n", - " else:\n", - " new_row[header[i]] = row[i]\n", + " val = cell(row_idx, header[i])\n", + " new_row[header[i]] = val\n", " dict_list.append(new_row)\n", " return dict_list\n", " \n", @@ -1027,7 +1035,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.7" + "version": "3.9.12" } }, "nbformat": 4, -- GitLab