From 4a4f994571ce1cbc7d84e70cae6de31fdecfcf3d Mon Sep 17 00:00:00 2001 From: liamlewis1030 <109105039+liamlewis1030@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:30:14 -0400 Subject: [PATCH 1/3] Created using Colaboratory --- MLB_rankings.ipynb | 63 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/MLB_rankings.ipynb b/MLB_rankings.ipynb index 495b7a2..8081542 100644 --- a/MLB_rankings.ipynb +++ b/MLB_rankings.ipynb @@ -6,7 +6,6 @@ "name": "MLB_rankings.ipynb", "provenance": [], "collapsed_sections": [], - "authorship_tag": "ABX9TyPyISm6N8ZsL/NvT4waBFNx", "include_colab_link": true }, "kernelspec": { @@ -25,7 +24,7 @@ "colab_type": "text" }, "source": [ - "\"Open" + "\"Open" ] }, { @@ -51,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "id": "Q1tgUhRoHXxW", "colab": { @@ -298,7 +297,7 @@ }, "outputId": "230be838-1e58-4209-fa99-5b773ccdafb8" }, - "execution_count": 6, + "execution_count": null, "outputs": [ { "output_type": "stream", @@ -330,7 +329,7 @@ "id": "Vl0ED4h8mIVM", "outputId": "34f7dc7b-b701-4bfc-d6e4-c3f580e18bf3" }, - "execution_count": 9, + "execution_count": null, "outputs": [ { "output_type": "execute_result", @@ -347,13 +346,59 @@ { "cell_type": "code", "source": [ - "# your code..." + "from __future__ import print_function\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "url = 'https://raw.githubusercontent.com/RodericGuigoCorominas/datascience/main/datasets/mlb_june_2022.csv'\n", + "df = pd.read_csv(url)\n", + "df\n", + "\n", + "pd.__version__\n", + "all_teams = np.unique(df[['home','visitor']].to_numpy().flatten())\n", + "num_teams = len(all_teams)\n", + "\n", + "print(\"There are\",num_teams,\"teams\")\n", + "print(all_teams)\n", + "\n", + "teams_dict = dict(zip(all_teams, range(num_teams)))" ], "metadata": { - "id": "h7pqt-a-nfUs" + "id": "h7pqt-a-nfUs", + "outputId": "be48c138-33ea-4877-ef44-61b4ec97b43f", + "colab": { + "base_uri": "https://localhost:8080/" + } }, - "execution_count": null, - "outputs": [] + "execution_count": 11, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "There are 30 teams\n", + "['Angels' 'Astros' 'Athletics' 'Blue Jays' 'Braves' 'Brewers' 'Cardinals'\n", + " 'Cubs' 'Diamondbacks' 'Dodgers' 'Giants' 'Guardians' 'Mariners' 'Marlins'\n", + " 'Mets' 'Nationals' 'Orioles' 'Padres' 'Phillies' 'Pirates' 'Rangers'\n", + " 'Rays' 'Red Sox' 'Reds' 'Rockies' 'Royals' 'Tigers' 'Twins' 'White Sox'\n", + " 'Yankees']\n", + " home visitor score home score visitor\n", + "0 Cubs Brewers 5 4\n", + "1 Royals Guardians 3 1\n", + "2 Cardinals Pirates 9 0\n", + "3 Nationals Mets 1 5\n", + "4 Braves Reds 3 6\n", + ".. ... ... ... ...\n", + "732 Rangers Rays 3 0\n", + "733 Cubs Brewers 8 7\n", + "734 Athletics Astros 1 3\n", + "735 Diamondbacks Braves 8 7\n", + "736 Dodgers Pirates 3 5\n", + "\n", + "[737 rows x 4 columns]\n" + ] + } + ] } ] } \ No newline at end of file From 200d807e6dd57cad1e0042b93970d2aaef1df783 Mon Sep 17 00:00:00 2001 From: liamlewis1030 <109105039+liamlewis1030@users.noreply.github.com> Date: Tue, 12 Jul 2022 17:53:59 -0400 Subject: [PATCH 2/3] Created using Colaboratory --- pset2.py | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 pset2.py diff --git a/pset2.py b/pset2.py new file mode 100644 index 0000000..9ce07c5 --- /dev/null +++ b/pset2.py @@ -0,0 +1,154 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "pset2.py", + "provenance": [], + "collapsed_sections": [], + "authorship_tag": "ABX9TyMaGtnwiKCplLYfoMtjFKrp", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "79fdlapYM8cp", + "outputId": "28469436-bf39-4ad7-9c9b-9d00e52dbf85" + }, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Average of a1 = 5.2\n" + ] + } + ], + "source": [ + "def average(l): \n", + " sum=0\n", + " for i in l:\n", + " sum=sum+i\n", + " avg = sum / len(l) \n", + " return avg\n", + " \n", + "a1 = [1,6,3,9,7] \n", + "average(a1) \n", + " \n", + "print(\"Average of a1 =\", average(a1))" + ] + }, + { + "cell_type": "code", + "source": [ + "a1 = [3,0]\n", + "a2 = [6,1,7]\n", + "def common(x,y):\n", + " w=False\n", + " for a in x:\n", + " for b in y:\n", + " print(a,b)\n", + " if a == b:\n", + " print(\"Common element!\")\n", + " w=True\n", + " return w\n", + "common(a1,a2)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "3tRtkucQNJH8", + "outputId": "6e89ce3c-febe-40eb-8864-17b0655d68f4" + }, + "execution_count": 68, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "3 6\n", + "3 1\n", + "3 7\n", + "0 6\n", + "0 1\n", + "0 7\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "False" + ] + }, + "metadata": {}, + "execution_count": 68 + } + ] + }, + { + "cell_type": "code", + "source": [ + "a1 = [3,7,12,16,-4,6,0,1,0]\n", + "def zerooo(x):\n", + " for a in x:\n", + " if a != 0:\n", + " print(a)\n", + " if a==0:\n", + " print('zerooo')\n", + "zerooo(a1)\n", + "print(a2)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "pCTii0kBNJ6u", + "outputId": "63b4381a-ac8a-4cf5-c453-acf6ce5e96d9" + }, + "execution_count": 94, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "3\n", + "7\n", + "12\n", + "16\n", + "-4\n", + "6\n", + "zerooo\n", + "1\n", + "zerooo\n", + "[6, 1, 7]\n" + ] + } + ] + } + ] +} \ No newline at end of file From af95de9e8f1bb644b6625425ccddd1b06d929d55 Mon Sep 17 00:00:00 2001 From: liamlewis1030 <109105039+liamlewis1030@users.noreply.github.com> Date: Tue, 12 Jul 2022 17:55:04 -0400 Subject: [PATCH 3/3] Created using Colaboratory --- pset2.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pset2.py b/pset2.py index 9ce07c5..9c3c2ca 100644 --- a/pset2.py +++ b/pset2.py @@ -6,7 +6,7 @@ "name": "pset2.py", "provenance": [], "collapsed_sections": [], - "authorship_tag": "ABX9TyMaGtnwiKCplLYfoMtjFKrp", + "authorship_tag": "ABX9TyMesRssz4skTykId0NvYhNM", "include_colab_link": true }, "kernelspec": { @@ -120,17 +120,16 @@ " print(a)\n", " if a==0:\n", " print('zerooo')\n", - "zerooo(a1)\n", - "print(a2)" + "zerooo(a1)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "pCTii0kBNJ6u", - "outputId": "63b4381a-ac8a-4cf5-c453-acf6ce5e96d9" + "outputId": "6c87d365-8d74-4cb5-9e67-763a57e68863" }, - "execution_count": 94, + "execution_count": 95, "outputs": [ { "output_type": "stream", @@ -144,8 +143,7 @@ "6\n", "zerooo\n", "1\n", - "zerooo\n", - "[6, 1, 7]\n" + "zerooo\n" ] } ]