{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "eeec3428", "metadata": {}, "outputs": [], "source": [ "# Copyright 2023 Google LLC\n", "#\n", "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", "# you may not use this file except in compliance with the License.\n", "# You may obtain a copy of the License at\n", "#\n", "# https://www.apache.org/licenses/LICENSE-2.0\n", "#\n", "# Unless required by applicable law or agreed to in writing, software\n", "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", "# See the License for the specific language governing permissions and\n", "# limitations under the License." ] }, { "attachments": {}, "cell_type": "markdown", "id": "47439dbd-4e54-4954-8b16-edc4bcd4f855", "metadata": {}, "source": [ "# Demo to Show DataFrame Operations" ] }, { "cell_type": "code", "execution_count": 1, "id": "96757c59-fc22-420e-a42f-c6cb956110ec", "metadata": {}, "outputs": [], "source": [ "import bigframes.pandas as bpd\n", "\n", "df = bpd.read_gbq(\"bigquery-public-data.baseball.schedules\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "13861abc-120c-4db6-ad0c-e414b85d3443", "metadata": {}, "source": [ "## Select a subset of the DF" ] }, { "cell_type": "code", "execution_count": 2, "id": "05cb36e9-bb75-4f6f-8eb6-e4219df6e1d2", "metadata": {}, "outputs": [], "source": [ "df = df[[\"gameId\", \"year\", \"homeTeamName\", \"awayTeamName\", \"duration_minutes\"]]" ] }, { "cell_type": "code", "execution_count": 3, "id": "f124234c-d292-4520-b9cc-a162e2b16d91", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job e6f77e72-820c-47ba-bd95-6b1ac360dc86 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 1280ea98-5503-4b32-899b-65ce4b4ad50f is DONE. 582.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df\n", "# Here starts real execution, may take a while" ] }, { "cell_type": "code", "execution_count": 4, "id": "a6b8b3ac-1df8-46ff-ac4f-d6e7657fc80c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2431, 5)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "attachments": {}, "cell_type": "markdown", "id": "efc9ccb5-4dee-4fb8-a95f-3a654421cec4", "metadata": {}, "source": [ "### Retrieve properties of the DF." ] }, { "cell_type": "code", "execution_count": 5, "id": "34457cc7-e734-4e3f-9f2b-34cdd4e2aba4", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "gameId string[pyarrow]\n", "year Int64\n", "homeTeamName string[pyarrow]\n", "awayTeamName string[pyarrow]\n", "duration_minutes Int64\n", "dtype: object" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.dtypes" ] }, { "cell_type": "code", "execution_count": 6, "id": "b4f4383f-f596-41d8-aad2-2fd68d261cfd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['gameId', 'year', 'homeTeamName', 'awayTeamName', 'duration_minutes'], dtype='object')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns" ] }, { "attachments": {}, "cell_type": "markdown", "id": "70e0a637-52ac-47cd-93e2-75d06d7a6170", "metadata": {}, "source": [ "### Add a new column" ] }, { "cell_type": "code", "execution_count": 7, "id": "c7017f3d-869d-42e3-bbd8-b3fbc408c2d0", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "Query job e8a94ab7-7833-43ac-bf14-bfd4310260b9 is DONE. 582.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 8b1e4a6c-9f93-4588-9c34-ae324a42fd57 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 18db85e7-c94f-46ec-b981-5c582b5ce22a is DONE. 261.3 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutestitle
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167Nationals vs Brewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172Reds vs Brewers
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166Orioles vs Rays
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182Rockies vs Giants
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204Twins vs Indians
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184Blue Jays vs Orioles
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182Yankees vs Mets
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191Red Sox vs Rays
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201Cardinals vs Pirates
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189Rays vs Twins
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177Rays vs Twins
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183Royals vs Rays
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194Astros vs Rays
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178Dodgers vs Giants
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193Tigers vs White Sox
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160Cardinals vs Cubs
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169Giants vs Cardinals
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251Red Sox vs Twins
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151Mets vs Braves
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153Athletics vs Twins
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185Twins vs Marlins
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180Twins vs Yankees
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199White Sox vs Orioles
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175Diamondbacks vs Giants
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201Braves vs Mets
\n", "

25 rows × 6 columns

\n", "
[2431 rows x 6 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes title \n", "0 167 Nationals vs Brewers \n", "1 172 Reds vs Brewers \n", "2 166 Orioles vs Rays \n", "3 182 Rockies vs Giants \n", "4 204 Twins vs Indians \n", "5 184 Blue Jays vs Orioles \n", "6 182 Yankees vs Mets \n", "7 191 Red Sox vs Rays \n", "8 201 Cardinals vs Pirates \n", "9 189 Rays vs Twins \n", "10 177 Rays vs Twins \n", "11 183 Royals vs Rays \n", "12 194 Astros vs Rays \n", "13 178 Dodgers vs Giants \n", "14 193 Tigers vs White Sox \n", "15 160 Cardinals vs Cubs \n", "16 169 Giants vs Cardinals \n", "17 251 Red Sox vs Twins \n", "18 151 Mets vs Braves \n", "19 153 Athletics vs Twins \n", "20 185 Twins vs Marlins \n", "21 180 Twins vs Yankees \n", "22 199 White Sox vs Orioles \n", "23 175 Diamondbacks vs Giants \n", "24 201 Braves vs Mets \n", "...\n", "\n", "[2431 rows x 6 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.assign(title=df['homeTeamName'] + \" vs \" + df['awayTeamName'])\n", "df" ] }, { "attachments": {}, "cell_type": "markdown", "id": "a4f9c18c-865e-4057-9e9a-85564f940c82", "metadata": {}, "source": [ "### Manipulate the column" ] }, { "cell_type": "code", "execution_count": 8, "id": "8bbe000a-36f0-4b6f-b403-b9ec28dd608b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job ef76c434-c4bc-4b4c-bb06-61521fc85b15 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job d3e413ee-c0c3-49fe-a2ad-f61d671593eb is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutesheadline
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167Nationals vs Brewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172Reds vs Brewers
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166Orioles vs Rays
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182Rockies vs Giants
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204Twins vs Indians
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184Blue Jays vs Orioles
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182Yankees vs Mets
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191Red Sox vs Rays
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201Cardinals vs Pirates
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189Rays vs Twins
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177Rays vs Twins
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183Royals vs Rays
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194Astros vs Rays
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178Dodgers vs Giants
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193Tigers vs White Sox
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160Cardinals vs Cubs
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169Giants vs Cardinals
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251Red Sox vs Twins
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151Mets vs Braves
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153Athletics vs Twins
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185Twins vs Marlins
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180Twins vs Yankees
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199White Sox vs Orioles
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175Diamondbacks vs Giants
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201Braves vs Mets
\n", "

25 rows × 6 columns

\n", "
[2431 rows x 6 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes headline \n", "0 167 Nationals vs Brewers \n", "1 172 Reds vs Brewers \n", "2 166 Orioles vs Rays \n", "3 182 Rockies vs Giants \n", "4 204 Twins vs Indians \n", "5 184 Blue Jays vs Orioles \n", "6 182 Yankees vs Mets \n", "7 191 Red Sox vs Rays \n", "8 201 Cardinals vs Pirates \n", "9 189 Rays vs Twins \n", "10 177 Rays vs Twins \n", "11 183 Royals vs Rays \n", "12 194 Astros vs Rays \n", "13 178 Dodgers vs Giants \n", "14 193 Tigers vs White Sox \n", "15 160 Cardinals vs Cubs \n", "16 169 Giants vs Cardinals \n", "17 251 Red Sox vs Twins \n", "18 151 Mets vs Braves \n", "19 153 Athletics vs Twins \n", "20 185 Twins vs Marlins \n", "21 180 Twins vs Yankees \n", "22 199 White Sox vs Orioles \n", "23 175 Diamondbacks vs Giants \n", "24 201 Braves vs Mets \n", "...\n", "\n", "[2431 rows x 6 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.rename(columns={\"title\": \"headline\"})\n", "df" ] }, { "cell_type": "code", "execution_count": 9, "id": "87eee643-28ac-4f4b-ac61-1f3de9c08a9d", "metadata": {}, "outputs": [], "source": [ "df = df.drop(columns=\"headline\")" ] }, { "cell_type": "code", "execution_count": 10, "id": "fad6d3da-1f40-4c5f-94ec-0bdfe21ca5b6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 051b3d23-5ab2-4022-adfc-f6553eb8532d is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job f7356669-04f8-46f9-bf9b-f8cd997d6162 is DONE. 213.3 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df" ] }, { "attachments": {}, "cell_type": "markdown", "id": "218b3d0f-ee0d-4a8a-8c7d-cf24825f3d3e", "metadata": {}, "source": [ "### Drop Nan values" ] }, { "cell_type": "code", "execution_count": 11, "id": "67a7c35f-80cf-4482-80f9-7f01c7743807", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job bd315bd7-1f10-4f1b-9997-10a294b1f464 is DONE. 232.7 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 972bf072-22c2-49ef-8764-1c1109dfc0a3 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 42c0cf8a-4276-479f-b8de-dcfce94ae42a is DONE. 213.3 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.dropna()\n", "df" ] }, { "attachments": {}, "cell_type": "markdown", "id": "80e9a2e2-c4c9-4c17-bbd0-06882d7657fe", "metadata": {}, "source": [ "### Join two DFs" ] }, { "cell_type": "code", "execution_count": 12, "id": "3f09ff32-ef43-4fab-a86b-8868afc34363", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 3c859587-582d-4b68-8b35-7072b9a42346 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 15bf1d87-152a-45a5-b000-e8e72ce6a982 is DONE. 152.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdhomeTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8Nationals
1af72a0b9-65f7-49fb-9b30-d505068bdf6dReds
2f57e1271-d217-400a-aea6-2e2d7d6a59a0Orioles
3198f4eed-a29f-41e2-8623-cb261e5ab370Rockies
4cb3ef033-dd57-41fd-b206-cdd3bc12c74fTwins
54be9f735-a98e-4689-87ce-852cc3a1e79dBlue Jays
60b2de8c3-11d9-4f0f-a186-25b59f34a5d8Yankees
760d80663-6ced-44aa-aad9-0f4bf8d3b4d2Red Sox
87e1c2095-4fea-454c-8773-096ceb6fb05cCardinals
9f7f24ce3-7f9d-4e8a-986e-095db847c4c1Rays
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe9Rays
116d2cab13-dd85-477a-8769-669069f85836Royals
12bca90342-7ddc-468e-b189-d43fad7528ecAstros
13630f4f78-03cc-43c1-9e57-ababb9c11418Dodgers
14c0cf1376-1115-4a2f-b457-3f82bbc41a89Tigers
1546463c50-0f5c-4dca-a661-dd194464e791Cardinals
16392ad56d-972e-4f77-98e2-5f8577931cf8Giants
17307730fa-bbed-4221-b4e6-a2492f546fd5Red Sox
181cbc558f-7615-4fa9-bf97-7ccd62040d6fMets
19723348ba-1645-43fc-9e22-92994f7a63bdAthletics
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992Twins
21f2747230-7df5-4535-a475-a1c823d0d654Twins
22db3b6f35-a7a4-430a-8703-2b2f25103e17White Sox
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636Diamondbacks
2495d548b6-2da8-4644-812e-b277fec5b91fBraves
\n", "

25 rows × 2 columns

\n", "
[2431 rows x 2 columns in total]" ], "text/plain": [ " gameId homeTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Nationals\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Reds\n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 Orioles\n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 Rockies\n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f Twins\n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d Blue Jays\n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 Yankees\n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 Red Sox\n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c Cardinals\n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 Rays\n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 Rays\n", "11 6d2cab13-dd85-477a-8769-669069f85836 Royals\n", "12 bca90342-7ddc-468e-b189-d43fad7528ec Astros\n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 Dodgers\n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 Tigers\n", "15 46463c50-0f5c-4dca-a661-dd194464e791 Cardinals\n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 Giants\n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 Red Sox\n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f Mets\n", "19 723348ba-1645-43fc-9e22-92994f7a63bd Athletics\n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 Twins\n", "21 f2747230-7df5-4535-a475-a1c823d0d654 Twins\n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 White Sox\n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 Diamondbacks\n", "24 95d548b6-2da8-4644-812e-b277fec5b91f Braves\n", "...\n", "\n", "[2431 rows x 2 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1 = df[[\"gameId\", \"homeTeamName\"]]\n", "df1" ] }, { "cell_type": "code", "execution_count": 13, "id": "5331d2c8-7912-4d96-8da1-f64b57374df3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 262a8d65-8eb7-4769-b26d-4a1d93f19950 is DONE. 152.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job a18f6c86-dbff-4846-8d21-8f8c1d700a80 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 9cc89303-be7a-4c34-b4c0-d1d75837a1e4 is DONE. 126 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdawayTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8Brewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6dBrewers
\n", "

2 rows × 2 columns

\n", "
[2 rows x 2 columns in total]" ], "text/plain": [ " gameId awayTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Brewers\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Brewers\n", "\n", "[2 rows x 2 columns]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2 = df[[\"gameId\", \"awayTeamName\"]].head(2)\n", "df2" ] }, { "cell_type": "code", "execution_count": 14, "id": "a574ad3e-a219-454c-8bb5-c5ed6627f2c6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 1edf3455-802d-4b93-900b-9677cb43955a is DONE. 133.5 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 98cccaa5-e630-4edf-bc15-2823e89aecb6 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 91af749e-6afa-488a-83da-1257667460f0 is DONE. 143 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdhomeTeamNameawayTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8NationalsBrewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6dRedsBrewers
\n", "

2 rows × 3 columns

\n", "
[2 rows x 3 columns in total]" ], "text/plain": [ " gameId homeTeamName awayTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Nationals Brewers\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Reds Brewers\n", "\n", "[2 rows x 3 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.merge(df2, on=\"gameId\", how=\"inner\")" ] }, { "cell_type": "code", "execution_count": 15, "id": "288e7a95-a077-46c4-8fe6-802474c01f8b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job dfe4d1ec-9a3d-4877-ab39-bb6f1c38d070 is DONE. 133.5 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 6261a857-d256-4051-8af5-c6b04fb2795f is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job df400799-b054-4969-83a0-089fb2b25fdd is DONE. 152.9 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdhomeTeamNameawayTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8NationalsBrewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6dRedsBrewers
2f57e1271-d217-400a-aea6-2e2d7d6a59a0Orioles<NA>
3198f4eed-a29f-41e2-8623-cb261e5ab370Rockies<NA>
4cb3ef033-dd57-41fd-b206-cdd3bc12c74fTwins<NA>
54be9f735-a98e-4689-87ce-852cc3a1e79dBlue Jays<NA>
60b2de8c3-11d9-4f0f-a186-25b59f34a5d8Yankees<NA>
760d80663-6ced-44aa-aad9-0f4bf8d3b4d2Red Sox<NA>
87e1c2095-4fea-454c-8773-096ceb6fb05cCardinals<NA>
9f7f24ce3-7f9d-4e8a-986e-095db847c4c1Rays<NA>
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe9Rays<NA>
116d2cab13-dd85-477a-8769-669069f85836Royals<NA>
12bca90342-7ddc-468e-b189-d43fad7528ecAstros<NA>
13630f4f78-03cc-43c1-9e57-ababb9c11418Dodgers<NA>
14c0cf1376-1115-4a2f-b457-3f82bbc41a89Tigers<NA>
1546463c50-0f5c-4dca-a661-dd194464e791Cardinals<NA>
16392ad56d-972e-4f77-98e2-5f8577931cf8Giants<NA>
17307730fa-bbed-4221-b4e6-a2492f546fd5Red Sox<NA>
181cbc558f-7615-4fa9-bf97-7ccd62040d6fMets<NA>
19723348ba-1645-43fc-9e22-92994f7a63bdAthletics<NA>
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992Twins<NA>
21f2747230-7df5-4535-a475-a1c823d0d654Twins<NA>
22db3b6f35-a7a4-430a-8703-2b2f25103e17White Sox<NA>
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636Diamondbacks<NA>
2495d548b6-2da8-4644-812e-b277fec5b91fBraves<NA>
\n", "

25 rows × 3 columns

\n", "
[2431 rows x 3 columns in total]" ], "text/plain": [ " gameId homeTeamName awayTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Nationals Brewers\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Reds Brewers\n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 Orioles \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 Rockies \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f Twins \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d Blue Jays \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 Yankees \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 Red Sox \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c Cardinals \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 Rays \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 Rays \n", "11 6d2cab13-dd85-477a-8769-669069f85836 Royals \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec Astros \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 Dodgers \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 Tigers \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 Cardinals \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 Giants \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 Red Sox \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f Mets \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd Athletics \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 Twins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 Twins \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 White Sox \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 Diamondbacks \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f Braves \n", "...\n", "\n", "[2431 rows x 3 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.merge(df2, on=\"gameId\", how=\"outer\")" ] }, { "cell_type": "code", "execution_count": 16, "id": "7ee87a01-2ff5-4021-855d-44b71cf2a225", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 9ae1e55b-36d0-4aef-ae39-67a3ad5fdb4d is DONE. 133.5 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 7a1822eb-7db9-4c54-abd5-74cb1cde6121 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 783d092c-5f79-4601-9365-633e48fac610 is DONE. 152.9 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdhomeTeamNameawayTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8NationalsBrewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6dRedsBrewers
2f57e1271-d217-400a-aea6-2e2d7d6a59a0Orioles<NA>
3198f4eed-a29f-41e2-8623-cb261e5ab370Rockies<NA>
4cb3ef033-dd57-41fd-b206-cdd3bc12c74fTwins<NA>
54be9f735-a98e-4689-87ce-852cc3a1e79dBlue Jays<NA>
60b2de8c3-11d9-4f0f-a186-25b59f34a5d8Yankees<NA>
760d80663-6ced-44aa-aad9-0f4bf8d3b4d2Red Sox<NA>
87e1c2095-4fea-454c-8773-096ceb6fb05cCardinals<NA>
9f7f24ce3-7f9d-4e8a-986e-095db847c4c1Rays<NA>
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe9Rays<NA>
116d2cab13-dd85-477a-8769-669069f85836Royals<NA>
12bca90342-7ddc-468e-b189-d43fad7528ecAstros<NA>
13630f4f78-03cc-43c1-9e57-ababb9c11418Dodgers<NA>
14c0cf1376-1115-4a2f-b457-3f82bbc41a89Tigers<NA>
1546463c50-0f5c-4dca-a661-dd194464e791Cardinals<NA>
16392ad56d-972e-4f77-98e2-5f8577931cf8Giants<NA>
17307730fa-bbed-4221-b4e6-a2492f546fd5Red Sox<NA>
181cbc558f-7615-4fa9-bf97-7ccd62040d6fMets<NA>
19723348ba-1645-43fc-9e22-92994f7a63bdAthletics<NA>
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992Twins<NA>
21f2747230-7df5-4535-a475-a1c823d0d654Twins<NA>
22db3b6f35-a7a4-430a-8703-2b2f25103e17White Sox<NA>
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636Diamondbacks<NA>
2495d548b6-2da8-4644-812e-b277fec5b91fBraves<NA>
\n", "

25 rows × 3 columns

\n", "
[2431 rows x 3 columns in total]" ], "text/plain": [ " gameId homeTeamName awayTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Nationals Brewers\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Reds Brewers\n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 Orioles \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 Rockies \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f Twins \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d Blue Jays \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 Yankees \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 Red Sox \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c Cardinals \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 Rays \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 Rays \n", "11 6d2cab13-dd85-477a-8769-669069f85836 Royals \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec Astros \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 Dodgers \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 Tigers \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 Cardinals \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 Giants \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 Red Sox \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f Mets \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd Athletics \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 Twins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 Twins \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 White Sox \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 Diamondbacks \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f Braves \n", "...\n", "\n", "[2431 rows x 3 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.merge(df2, on=\"gameId\", how=\"left\")" ] }, { "cell_type": "code", "execution_count": 17, "id": "330ed69c-f122-4af9-bf5e-96e309d3fa0c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job ec1c442e-6ea1-461c-ada7-e3dd0454b0ca is DONE. 133.5 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 4ababa83-ad57-4520-b49d-e613256ae2f3 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job f3db2d14-b877-46ea-8858-5cdb3706e26a is DONE. 143 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdhomeTeamNameawayTeamName
0d60c6036-0ce1-4c90-8dd9-de3b403c92a8NationalsBrewers
1af72a0b9-65f7-49fb-9b30-d505068bdf6dRedsBrewers
\n", "

2 rows × 3 columns

\n", "
[2 rows x 3 columns in total]" ], "text/plain": [ " gameId homeTeamName awayTeamName\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 Nationals Brewers\n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d Reds Brewers\n", "\n", "[2 rows x 3 columns]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.merge(df2, on=\"gameId\", how=\"right\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "ea42b463-f37b-4ea4-805f-a16a84b656e4", "metadata": {}, "source": [ "### Concat two DFs" ] }, { "cell_type": "code", "execution_count": 18, "id": "5181231e-8a2a-4ac5-a379-6aa5ad4fee89", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job f0e1bda5-34f5-46e2-a396-289340074f82 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job e7195b4a-f1ea-4bef-a4db-fa817144d249 is DONE. 213.3 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeamNameawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[4862 rows x 5 columns in total]" ], "text/plain": [ " gameId year homeTeamName awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[4862 rows x 5 columns]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bpd.concat([df, df])" ] }, { "attachments": {}, "cell_type": "markdown", "id": "dcddbc12-3f17-43f5-a829-84d8093c7760", "metadata": {}, "source": [ "### Access column through property" ] }, { "cell_type": "code", "execution_count": 19, "id": "ad1f86f1-890b-462b-b408-b94c073371ff", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 0745cde9-9175-4e11-9721-f0c58fae90a2 is DONE. 79.9 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 4c7a65d6-63b7-44b6-8249-171139f907f5 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job cee24fe1-cb33-4836-b158-90e293cbc057 is DONE. 60.5 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "0 Nationals\n", "1 Reds\n", "2 Orioles\n", "3 Rockies\n", "4 Twins\n", "5 Blue Jays\n", "6 Yankees\n", "7 Red Sox\n", "8 Cardinals\n", "9 Rays\n", "10 Rays\n", "11 Royals\n", "12 Astros\n", "13 Dodgers\n", "14 Tigers\n", "15 Cardinals\n", "16 Giants\n", "17 Red Sox\n", "18 Mets\n", "19 Athletics\n", "20 Twins\n", "21 Twins\n", "22 White Sox\n", "23 Diamondbacks\n", "24 Braves\n", "Name: homeTeamName, dtype: string" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.homeTeamName" ] }, { "attachments": {}, "cell_type": "markdown", "id": "4ae2e978-ac96-4c6a-8be8-9df9424c3544", "metadata": {}, "source": [ "### Retrieve SQL" ] }, { "cell_type": "code", "execution_count": 28, "id": "2ae4924b-37a9-4327-81d4-4f2afb66cb37", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WITH t0 AS (\n", " SELECT\n", " t9.`col_13`,\n", " t9.`col_14`,\n", " t9.`col_17`,\n", " t9.`bigframes_ordering_id`\n", " FROM `swast-scratch`._63cfa399614a54153cc386c27d6c0c6fdb249f9e.bqdf20240315_0f214503ed3e408abae057064ac2b4c2 AS t9\n", "), t1 AS (\n", " SELECT\n", " t9.`col_13`,\n", " t9.`col_14`,\n", " t9.`col_16`,\n", " t9.`hidden_l_0`,\n", " t9.`hidden_r_0`\n", " FROM `swast-scratch`._63cfa399614a54153cc386c27d6c0c6fdb249f9e.bqdf20240315_22c51834c2b94bbc93da3d0ff27f980f AS t9\n", "), t2 AS (\n", " SELECT\n", " t0.`col_13`,\n", " t0.`col_14`,\n", " t0.`col_17`,\n", " t0.`bigframes_ordering_id`\n", " FROM t0\n", "), t3 AS (\n", " SELECT\n", " t1.`col_13`,\n", " t1.`col_14`,\n", " t1.`col_16`,\n", " t1.`hidden_l_0`,\n", " t1.`hidden_r_0`\n", " FROM t1\n", "), t4 AS (\n", " SELECT\n", " t2.`col_13` AS `col_103`,\n", " t2.`col_14` AS `col_104`,\n", " t2.`col_17` AS `col_105`,\n", " t2.`bigframes_ordering_id` AS `hidden_r_0`\n", " FROM t2\n", "), t5 AS (\n", " SELECT\n", " t3.`col_13` AS `col_100`,\n", " t3.`col_14` AS `col_101`,\n", " t3.`col_16` AS `col_102`,\n", " t3.`hidden_l_0`,\n", " t3.`hidden_r_0` AS `hidden_l_1`\n", " FROM t3\n", "), t6 AS (\n", " SELECT\n", " coalesce(`col_101`, `col_104`) AS `col_106`,\n", " `col_102`,\n", " `col_105`,\n", " (\n", " row_number() OVER (ORDER BY `hidden_l_0` IS NULL ASC, `hidden_l_0` ASC, `hidden_r_0` IS NULL ASC, `hidden_r_0` ASC) - 1\n", " ) AS `bigframes_ordering_id`\n", " FROM t5\n", " INNER JOIN t4\n", " ON coalesce(t5.`col_101`, '$NULL_SENTINEL$') = coalesce(t4.`col_104`, '$NULL_SENTINEL$')\n", "), t7 AS (\n", " SELECT\n", " t6.`col_106`,\n", " t6.`col_102`,\n", " t6.`col_105`,\n", " t6.`bigframes_ordering_id`\n", " FROM t6\n", ")\n", "SELECT\n", " t8.`col_106` AS `gameId`,\n", " t8.`col_102` AS `homeTeamName`,\n", " t8.`col_105` AS `awayTeamName`\n", "FROM (\n", " SELECT\n", " t7.`col_106`,\n", " t7.`col_102`,\n", " t7.`col_105`\n", " FROM t7\n", ") AS t8\n" ] } ], "source": [ "print(df1.merge(df2, on=\"gameId\", how=\"inner\").sql)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "cec555be-0773-45e0-9008-86cd3e645285", "metadata": {}, "source": [ "### Special Column Names" ] }, { "cell_type": "code", "execution_count": 21, "id": "5adc7bbf-2c58-4924-964c-ed1b18dc9268", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 9fcba646-219f-40ee-9792-d74af0ff7e22 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 657cdf62-f71e-482c-97f7-b66e4ac20e10 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearHOME TEAMawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year HOME TEAM awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.rename(columns={\"homeTeamName\": \"HOME TEAM\"})" ] }, { "cell_type": "code", "execution_count": 22, "id": "ac3ceabe-4317-453c-9418-826de5094454", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job c90e0cd4-30e5-427c-8f5f-a0a8c778bc62 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 23bfdb6d-9411-484c-9766-93f76dfc1adc is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearhomeTeam!@#$%colawayTeamNameduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year homeTeam!@#$%col awayTeamName \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.rename(columns={\"homeTeamName\": \"homeTeam!@#$%col\"})" ] }, { "cell_type": "code", "execution_count": 23, "id": "e73704c9-7aa9-4f10-b414-3417c3ad9eb8", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 63c2d27f-382c-4a43-8fc1-135d9fd66a54 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job cc64185b-98e7-40d8-bf8e-2a3ea355ef67 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
gameIdyearteamteamduration_minutes
0d60c6036-0ce1-4c90-8dd9-de3b403c92a82016NationalsBrewers167
1af72a0b9-65f7-49fb-9b30-d505068bdf6d2016RedsBrewers172
2f57e1271-d217-400a-aea6-2e2d7d6a59a02016OriolesRays166
3198f4eed-a29f-41e2-8623-cb261e5ab3702016RockiesGiants182
4cb3ef033-dd57-41fd-b206-cdd3bc12c74f2016TwinsIndians204
54be9f735-a98e-4689-87ce-852cc3a1e79d2016Blue JaysOrioles184
60b2de8c3-11d9-4f0f-a186-25b59f34a5d82016YankeesMets182
760d80663-6ced-44aa-aad9-0f4bf8d3b4d22016Red SoxRays191
87e1c2095-4fea-454c-8773-096ceb6fb05c2016CardinalsPirates201
9f7f24ce3-7f9d-4e8a-986e-095db847c4c12016RaysTwins189
105c26e7fc-c99f-48b4-92c1-4a7208c8cfe92016RaysTwins177
116d2cab13-dd85-477a-8769-669069f858362016RoyalsRays183
12bca90342-7ddc-468e-b189-d43fad7528ec2016AstrosRays194
13630f4f78-03cc-43c1-9e57-ababb9c114182016DodgersGiants178
14c0cf1376-1115-4a2f-b457-3f82bbc41a892016TigersWhite Sox193
1546463c50-0f5c-4dca-a661-dd194464e7912016CardinalsCubs160
16392ad56d-972e-4f77-98e2-5f8577931cf82016GiantsCardinals169
17307730fa-bbed-4221-b4e6-a2492f546fd52016Red SoxTwins251
181cbc558f-7615-4fa9-bf97-7ccd62040d6f2016MetsBraves151
19723348ba-1645-43fc-9e22-92994f7a63bd2016AthleticsTwins153
20ffbd6ecc-82e1-4e5d-9bd1-4ea210be59922016TwinsMarlins185
21f2747230-7df5-4535-a475-a1c823d0d6542016TwinsYankees180
22db3b6f35-a7a4-430a-8703-2b2f25103e172016White SoxOrioles199
235fc8c6f0-a70e-4d1b-877f-eb1ec8e6f6362016DiamondbacksGiants175
2495d548b6-2da8-4644-812e-b277fec5b91f2016BravesMets201
\n", "

25 rows × 5 columns

\n", "
[2431 rows x 5 columns in total]" ], "text/plain": [ " gameId year team team \\\n", "0 d60c6036-0ce1-4c90-8dd9-de3b403c92a8 2016 Nationals Brewers \n", "1 af72a0b9-65f7-49fb-9b30-d505068bdf6d 2016 Reds Brewers \n", "2 f57e1271-d217-400a-aea6-2e2d7d6a59a0 2016 Orioles Rays \n", "3 198f4eed-a29f-41e2-8623-cb261e5ab370 2016 Rockies Giants \n", "4 cb3ef033-dd57-41fd-b206-cdd3bc12c74f 2016 Twins Indians \n", "5 4be9f735-a98e-4689-87ce-852cc3a1e79d 2016 Blue Jays Orioles \n", "6 0b2de8c3-11d9-4f0f-a186-25b59f34a5d8 2016 Yankees Mets \n", "7 60d80663-6ced-44aa-aad9-0f4bf8d3b4d2 2016 Red Sox Rays \n", "8 7e1c2095-4fea-454c-8773-096ceb6fb05c 2016 Cardinals Pirates \n", "9 f7f24ce3-7f9d-4e8a-986e-095db847c4c1 2016 Rays Twins \n", "10 5c26e7fc-c99f-48b4-92c1-4a7208c8cfe9 2016 Rays Twins \n", "11 6d2cab13-dd85-477a-8769-669069f85836 2016 Royals Rays \n", "12 bca90342-7ddc-468e-b189-d43fad7528ec 2016 Astros Rays \n", "13 630f4f78-03cc-43c1-9e57-ababb9c11418 2016 Dodgers Giants \n", "14 c0cf1376-1115-4a2f-b457-3f82bbc41a89 2016 Tigers White Sox \n", "15 46463c50-0f5c-4dca-a661-dd194464e791 2016 Cardinals Cubs \n", "16 392ad56d-972e-4f77-98e2-5f8577931cf8 2016 Giants Cardinals \n", "17 307730fa-bbed-4221-b4e6-a2492f546fd5 2016 Red Sox Twins \n", "18 1cbc558f-7615-4fa9-bf97-7ccd62040d6f 2016 Mets Braves \n", "19 723348ba-1645-43fc-9e22-92994f7a63bd 2016 Athletics Twins \n", "20 ffbd6ecc-82e1-4e5d-9bd1-4ea210be5992 2016 Twins Marlins \n", "21 f2747230-7df5-4535-a475-a1c823d0d654 2016 Twins Yankees \n", "22 db3b6f35-a7a4-430a-8703-2b2f25103e17 2016 White Sox Orioles \n", "23 5fc8c6f0-a70e-4d1b-877f-eb1ec8e6f636 2016 Diamondbacks Giants \n", "24 95d548b6-2da8-4644-812e-b277fec5b91f 2016 Braves Mets \n", "\n", " duration_minutes \n", "0 167 \n", "1 172 \n", "2 166 \n", "3 182 \n", "4 204 \n", "5 184 \n", "6 182 \n", "7 191 \n", "8 201 \n", "9 189 \n", "10 177 \n", "11 183 \n", "12 194 \n", "13 178 \n", "14 193 \n", "15 160 \n", "16 169 \n", "17 251 \n", "18 151 \n", "19 153 \n", "20 185 \n", "21 180 \n", "22 199 \n", "23 175 \n", "24 201 \n", "...\n", "\n", "[2431 rows x 5 columns]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df3 = df.rename(columns={\"homeTeamName\": \"team\", \"awayTeamName\": \"team\"})\n", "df3" ] }, { "cell_type": "code", "execution_count": 24, "id": "1a80f6f8-a172-4d7d-a2f5-e10871da7224", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job 089a657b-e651-4b17-a4ce-4d7be682a49c is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job 740ad61e-cf14-41f1-ae4e-23d1fb8ed155 is DONE. 82.0 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
teamteam
0NationalsBrewers
1RedsBrewers
2OriolesRays
3RockiesGiants
4TwinsIndians
5Blue JaysOrioles
6YankeesMets
7Red SoxRays
8CardinalsPirates
9RaysTwins
10RaysTwins
11RoyalsRays
12AstrosRays
13DodgersGiants
14TigersWhite Sox
15CardinalsCubs
16GiantsCardinals
17Red SoxTwins
18MetsBraves
19AthleticsTwins
20TwinsMarlins
21TwinsYankees
22White SoxOrioles
23DiamondbacksGiants
24BravesMets
\n", "

25 rows × 2 columns

\n", "
[2431 rows x 2 columns in total]" ], "text/plain": [ " team team\n", "0 Nationals Brewers\n", "1 Reds Brewers\n", "2 Orioles Rays\n", "3 Rockies Giants\n", "4 Twins Indians\n", "5 Blue Jays Orioles\n", "6 Yankees Mets\n", "7 Red Sox Rays\n", "8 Cardinals Pirates\n", "9 Rays Twins\n", "10 Rays Twins\n", "11 Royals Rays\n", "12 Astros Rays\n", "13 Dodgers Giants\n", "14 Tigers White Sox\n", "15 Cardinals Cubs\n", "16 Giants Cardinals\n", "17 Red Sox Twins\n", "18 Mets Braves\n", "19 Athletics Twins\n", "20 Twins Marlins\n", "21 Twins Yankees\n", "22 White Sox Orioles\n", "23 Diamondbacks Giants\n", "24 Braves Mets\n", "...\n", "\n", "[2431 rows x 2 columns]" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df3[\"team\"]" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8e1a4dc8-de23-466e-8ead-df4af82a8085", "metadata": {}, "source": [ "### Binary Operation" ] }, { "cell_type": "code", "execution_count": 25, "id": "2414a095-37df-4755-b86c-2031a6cb9d4a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job d3b3cd83-d9cf-4c5b-9015-e3979e0857f3 is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job e4d99a58-738d-42af-863e-d1262a32c93c is DONE. 77.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearduration_minutes
02016167
12016172
22016166
32016182
42016204
52016184
62016182
72016191
82016201
92016189
102016177
112016183
122016194
132016178
142016193
152016160
162016169
172016251
182016151
192016153
202016185
212016180
222016199
232016175
242016201
\n", "

25 rows × 2 columns

\n", "
[2431 rows x 2 columns in total]" ], "text/plain": [ " year duration_minutes\n", "0 2016 167\n", "1 2016 172\n", "2 2016 166\n", "3 2016 182\n", "4 2016 204\n", "5 2016 184\n", "6 2016 182\n", "7 2016 191\n", "8 2016 201\n", "9 2016 189\n", "10 2016 177\n", "11 2016 183\n", "12 2016 194\n", "13 2016 178\n", "14 2016 193\n", "15 2016 160\n", "16 2016 169\n", "17 2016 251\n", "18 2016 151\n", "19 2016 153\n", "20 2016 185\n", "21 2016 180\n", "22 2016 199\n", "23 2016 175\n", "24 2016 201\n", "...\n", "\n", "[2431 rows x 2 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df4 = df[[\"year\", \"duration_minutes\"]]\n", "df4" ] }, { "cell_type": "code", "execution_count": 26, "id": "7d437c7c-ae74-4f0d-a4f8-10a133f4b61e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job e5c2b908-c539-4349-8368-50e61d8e19cd is DONE. 0 Bytes processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "Query job c5a563d2-9780-4c51-996b-bf0242b96e39 is DONE. 77.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearduration_minutes
02017168
12017173
22017167
32017183
42017205
52017185
62017183
72017192
82017202
92017190
102017178
112017184
122017195
132017179
142017194
152017161
162017170
172017252
182017152
192017154
202017186
212017181
222017200
232017176
242017202
\n", "

25 rows × 2 columns

\n", "
[2431 rows x 2 columns in total]" ], "text/plain": [ " year duration_minutes\n", "0 2017 168\n", "1 2017 173\n", "2 2017 167\n", "3 2017 183\n", "4 2017 205\n", "5 2017 185\n", "6 2017 183\n", "7 2017 192\n", "8 2017 202\n", "9 2017 190\n", "10 2017 178\n", "11 2017 184\n", "12 2017 195\n", "13 2017 179\n", "14 2017 194\n", "15 2017 161\n", "16 2017 170\n", "17 2017 252\n", "18 2017 152\n", "19 2017 154\n", "20 2017 186\n", "21 2017 181\n", "22 2017 200\n", "23 2017 176\n", "24 2017 202\n", "...\n", "\n", "[2431 rows x 2 columns]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df4 + 1" ] }, { "cell_type": "markdown", "id": "162eede7", "metadata": {}, "source": [ "### Download the result as (in-memory) pandas DataFrame" ] }, { "cell_type": "code", "execution_count": 27, "id": "ab429fa5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "Query job b6495f3d-619c-429e-8904-5cdc4957d09f is DONE. 77.8 kB processed. Open Job" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yearduration_minutes
02016167
12016172
22016166
32016182
42016204
.........
24262016199
24272016181
24282016205
24292016203
24302016182
\n", "

2431 rows × 2 columns

\n", "
" ], "text/plain": [ " year duration_minutes\n", "0 2016 167\n", "1 2016 172\n", "2 2016 166\n", "3 2016 182\n", "4 2016 204\n", "... ... ...\n", "2426 2016 199\n", "2427 2016 181\n", "2428 2016 205\n", "2429 2016 203\n", "2430 2016 182\n", "\n", "[2431 rows x 2 columns]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dfp = df4.to_pandas()\n", "dfp" ] } ], "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.11.1" } }, "nbformat": 4, "nbformat_minor": 5 }