{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2016 Phillies Games Broadcast on National Television\n", "\n", "I like watching the Phillies. I do not have cable. Some Phillies games are broadcast on national television. This is how I made a list of those games.\n", "\n", "## [Pandas](http://pandas.pydata.org/)\n", "\n", "Pandas is a data analysis tool for the [Python](https://www.python.org/) programming language. It can do a tremendous amount of really powerful data analysis and visualization. It's a gun in this CSV knife fight." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A downloadable [CSV schedule](http://philadelphia.phillies.mlb.com/schedule/downloadable.jsp#csv-format) is available from [mlb.com](http://mlb.com). Here is a [direct link](http://mlb.mlb.com/ticketing-client/csv/EventTicketPromotionPrice.tiksrv?team_id=108&display_in=singlegame&ticket_category=Tickets&site_section=Default&sub_category=Default&leave_empty_games=true&event_type=T&event_type=Y) to the Phillies schedule.\n", "\n", "The CSV schedule will be used to instantiate a Pandas [DataFrame](http://pandas.pydata.org/pandas-docs/version/0.13.1/generated/pandas.DataFrame.html) object." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "schedule = pd.DataFrame.from_csv(\"phillies-2016.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What does the schedule metadata look like?" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "DatetimeIndex: 190 entries, 2016-03-07 to 2016-10-02\n", "Data columns (total 16 columns):\n", "START TIME 189 non-null object\n", "START TIME ET 189 non-null object\n", "SUBJECT 190 non-null object\n", "LOCATION 190 non-null object\n", "DESCRIPTION 187 non-null object\n", "END DATE 190 non-null object\n", "END DATE ET 190 non-null object\n", "END TIME 189 non-null object\n", "END TIME ET 189 non-null object\n", "REMINDER OFF 190 non-null bool\n", "REMINDER ON 190 non-null bool\n", "REMINDER DATE 190 non-null object\n", "REMINDER TIME 189 non-null object\n", "REMINDER TIME ET 189 non-null object\n", "SHOWTIMEAS FREE 190 non-null object\n", "SHOWTIMEAS BUSY 190 non-null object\n", "dtypes: bool(2), object(14)\n", "memory usage: 22.6+ KB\n" ] } ], "source": [ "schedule.info()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "190 games and 16 columns of data for each game. \n", "\n", "## What does the schedule data itself look like?" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "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", "
START TIMESTART TIME ETSUBJECTLOCATIONDESCRIPTIONEND DATEEND DATE ETEND TIMEEND TIME ETREMINDER OFFREMINDER ONREMINDER DATEREMINDER TIMEREMINDER TIME ETSHOWTIMEAS FREESHOWTIMEAS BUSY
START DATE
2016-03-0701:05 PM01:05 PMPhillies at PiratesMcKechnie Field - BradentonLocal TV: MLB.TV ----- Local Radio: MLB.com03/07/1603/07/1604:05 PM04:05 PMFalseTrue03/07/1612:05 PM12:05 PMFREEBUSY
2016-03-0801:05 PM01:05 PMPirates at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLB.TV03/08/1603/08/1604:05 PM04:05 PMFalseTrue03/08/1612:05 PM12:05 PMFREEBUSY
2016-03-0901:05 PM01:05 PMPhillies at TwinsCenturyLink Sports Complex - Fort MyersNaN03/09/1603/09/1604:05 PM04:05 PMFalseTrue03/09/1612:05 PM12:05 PMFREEBUSY
2016-03-0901:05 PM01:05 PMOrioles at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLB.TV03/09/1603/09/1604:05 PM04:05 PMFalseTrue03/09/1612:05 PM12:05 PMFREEBUSY
2016-03-1001:05 PM01:05 PMTigers at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLBN- MLB.TV03/10/1603/10/1604:05 PM04:05 PMFalseTrue03/10/1612:05 PM12:05 PMFREEBUSY
\n", "
" ], "text/plain": [ " START TIME START TIME ET SUBJECT \\\n", "START DATE \n", "2016-03-07 01:05 PM 01:05 PM Phillies at Pirates \n", "2016-03-08 01:05 PM 01:05 PM Pirates at Phillies \n", "2016-03-09 01:05 PM 01:05 PM Phillies at Twins \n", "2016-03-09 01:05 PM 01:05 PM Orioles at Phillies \n", "2016-03-10 01:05 PM 01:05 PM Tigers at Phillies \n", "\n", " LOCATION \\\n", "START DATE \n", "2016-03-07 McKechnie Field - Bradenton \n", "2016-03-08 Bright House Field - Clearwater \n", "2016-03-09 CenturyLink Sports Complex - Fort Myers \n", "2016-03-09 Bright House Field - Clearwater \n", "2016-03-10 Bright House Field - Clearwater \n", "\n", " DESCRIPTION END DATE END DATE ET \\\n", "START DATE \n", "2016-03-07 Local TV: MLB.TV ----- Local Radio: MLB.com 03/07/16 03/07/16 \n", "2016-03-08 Local TV: TCN- MLB.TV 03/08/16 03/08/16 \n", "2016-03-09 NaN 03/09/16 03/09/16 \n", "2016-03-09 Local TV: TCN- MLB.TV 03/09/16 03/09/16 \n", "2016-03-10 Local TV: TCN- MLBN- MLB.TV 03/10/16 03/10/16 \n", "\n", " END TIME END TIME ET REMINDER OFF REMINDER ON REMINDER DATE \\\n", "START DATE \n", "2016-03-07 04:05 PM 04:05 PM False True 03/07/16 \n", "2016-03-08 04:05 PM 04:05 PM False True 03/08/16 \n", "2016-03-09 04:05 PM 04:05 PM False True 03/09/16 \n", "2016-03-09 04:05 PM 04:05 PM False True 03/09/16 \n", "2016-03-10 04:05 PM 04:05 PM False True 03/10/16 \n", "\n", " REMINDER TIME REMINDER TIME ET SHOWTIMEAS FREE SHOWTIMEAS BUSY \n", "START DATE \n", "2016-03-07 12:05 PM 12:05 PM FREE BUSY \n", "2016-03-08 12:05 PM 12:05 PM FREE BUSY \n", "2016-03-09 12:05 PM 12:05 PM FREE BUSY \n", "2016-03-09 12:05 PM 12:05 PM FREE BUSY \n", "2016-03-10 12:05 PM 12:05 PM FREE BUSY " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "schedule.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cleaning up the schedule\n", "\n", "The `DESCRIPTION` column contains the broadcast information. Less interesting columns can be removed." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "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", "
START TIMESUBJECTLOCATIONDESCRIPTION
START DATE
2016-03-0701:05 PMPhillies at PiratesMcKechnie Field - BradentonLocal TV: MLB.TV ----- Local Radio: MLB.com
2016-03-0801:05 PMPirates at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLB.TV
2016-03-0901:05 PMPhillies at TwinsCenturyLink Sports Complex - Fort MyersNaN
2016-03-0901:05 PMOrioles at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLB.TV
2016-03-1001:05 PMTigers at PhilliesBright House Field - ClearwaterLocal TV: TCN- MLBN- MLB.TV
\n", "
" ], "text/plain": [ " START TIME SUBJECT \\\n", "START DATE \n", "2016-03-07 01:05 PM Phillies at Pirates \n", "2016-03-08 01:05 PM Pirates at Phillies \n", "2016-03-09 01:05 PM Phillies at Twins \n", "2016-03-09 01:05 PM Orioles at Phillies \n", "2016-03-10 01:05 PM Tigers at Phillies \n", "\n", " LOCATION \\\n", "START DATE \n", "2016-03-07 McKechnie Field - Bradenton \n", "2016-03-08 Bright House Field - Clearwater \n", "2016-03-09 CenturyLink Sports Complex - Fort Myers \n", "2016-03-09 Bright House Field - Clearwater \n", "2016-03-10 Bright House Field - Clearwater \n", "\n", " DESCRIPTION \n", "START DATE \n", "2016-03-07 Local TV: MLB.TV ----- Local Radio: MLB.com \n", "2016-03-08 Local TV: TCN- MLB.TV \n", "2016-03-09 NaN \n", "2016-03-09 Local TV: TCN- MLB.TV \n", "2016-03-10 Local TV: TCN- MLBN- MLB.TV " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "schedule.drop([\"REMINDER OFF\", \n", " \"REMINDER ON\",\n", " \"START TIME ET\",\n", " \"END DATE\",\n", " \"END DATE ET\",\n", " \"END TIME\",\n", " \"END TIME ET\",\n", " \"REMINDER TIME\",\n", " \"REMINDER TIME ET\",\n", " \"SHOWTIMEAS FREE\",\n", " \"SHOWTIMEAS BUSY\",\n", " \"REMINDER DATE\"], axis=1, inplace=True)\n", "schedule.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What are all of the stations that games are broadcast on this season?\n", "\n", "The `DESCRIPTION` column is nice because it mentions the stations that games are broadcast on. Sometimes a game is broadcast on two channels at once. There is also radio broadcast information that I'm not interested in right now." ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "START DATE\n", "2016-03-07 Local TV: MLB.TV ----- Local Radio: MLB.com\n", "2016-03-08 Local TV: TCN- MLB.TV\n", "2016-03-09 NaN\n", "2016-03-09 Local TV: TCN- MLB.TV\n", "2016-03-10 Local TV: TCN- MLBN- MLB.TV\n", "2016-03-11 Local Radio: MLB.com\n", "2016-03-12 Local TV: CSN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-13 Local TV: MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-14 Local Radio: MLB.com\n", "2016-03-15 Local Radio: MLB.com\n", "2016-03-17 Local TV: TCN- MLB.TV\n", "2016-03-18 Local TV: TCN- MLB.TV\n", "2016-03-19 Local TV: MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-20 Local TV: CSN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-21 Local Radio: MLB.com\n", "2016-03-22 Local TV: TCN- MLB.TV\n", "2016-03-23 Local Radio: 94 WIP\n", "2016-03-24 Local TV: MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-25 Local TV: CSN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-26 Local TV: CSN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-27 Local TV: MLB.TV ----- Local Radio: 94 WIP\n", "2016-03-28 NaN\n", "2016-03-29 Local TV: TCN- MLBN- MLB.TV\n", "2016-03-30 Local TV: TCN- MLB.TV\n", "2016-03-31 Local TV: TCN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-04-01 Local TV: TCN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-04-02 Local TV: TCN- MLB.TV ----- Local Radio: 94 WIP\n", "2016-04-04 Local TV: CSN\n", "2016-04-06 Local TV: CSN- ESPN2\n", "2016-04-07 Local TV: CSN\n", "2016-04-08 Local TV: CSN\n", "2016-04-09 Local TV: CSN\n", "2016-04-10 Local TV: TCN\n", "2016-04-11 Local TV: NBC 10\n", "2016-04-12 Local TV: TCN\n", "2016-04-13 Local TV: TCN\n", "2016-04-14 Local TV: CSN\n", "2016-04-15 Local TV: CSN\n", "2016-04-16 Local TV: CSN\n", "2016-04-17 Local TV: CSN\n", "2016-04-18 Local TV: CSN\n", "2016-04-19 Local TV: CSN\n", "2016-04-20 Local TV: CSN\n", "2016-04-22 Local TV: TCN\n", "2016-04-23 Local TV: CSN\n", "2016-04-24 Local TV: CSN\n", "2016-04-26 Local TV: CSN\n", "2016-04-27 Local TV: CSN\n", "2016-04-28 Local TV: CSN\n", "2016-04-29 Local TV: CSN\n", "Name: DESCRIPTION, dtype: object" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "schedule.DESCRIPTION.head(50)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Parse television station broadcast channels from `DESCRIPTION`\n", "\n", "Thankfully, the `DESCRIPTION` column data is parseable. Getting a list of television broadcast stations for each game is not _too_ difficult." ] }, { "cell_type": "code", "execution_count": 73, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Local TV: CSN- MLB.TV ----- Local Radio: 94 WIP\n" ] } ], "source": [ "description = schedule.DESCRIPTION[6]\n", "print description" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Grab the rough station string with a regular expression." ] }, { "cell_type": "code", "execution_count": 123, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import re\n", "\n", "TV_STATION_RE = re.compile(r\"\"\"Local\\s+TV:\\s+ # TV token\n", " (?P.*) # Group everything following it lazily as stations\n", " \"\"\", re.X)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use that to pull them out and do some text wrangling." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def tv_stations_from_description(description):\n", " \"\"\"Return a list of television stations embedded in the given description.\"\"\"\n", " tv_stations = []\n", " result = re.search(TV_STATION_RE, str(description))\n", " if result:\n", " media_delimiter = \"-----\"\n", " tv_station_str = result.group(\"stations\").split(media_delimiter)[0]\n", " tv_stations = tv_station_str.split(\"- \")\n", " tv_stations = [s.strip() for s in tv_stations]\n", " return tv_stations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Test it out on all of the descriptions." ] }, { "cell_type": "code", "execution_count": 126, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'CSN', 'ESPN2', 'MLB.TV', 'MLBN', 'NBC 10', 'TCN'}" ] }, "execution_count": 126, "metadata": {}, "output_type": "execute_result" } ], "source": [ "tv_stations = set()\n", "for d in schedule.DESCRIPTION:\n", " tv_stations |= set(tv_stations_from_description(d))\n", "tv_stations " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Applying this function to the DataFrame yields a [`Series`](http://pandas.pydata.org/pandas-docs/stable/dsintro.html#series) of all television stations on which the Phillies are broadcast this season." ] }, { "cell_type": "code", "execution_count": 127, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "START DATE\n", "2016-03-07 [MLB.TV]\n", "2016-03-08 [TCN, MLB.TV]\n", "2016-03-09 []\n", "2016-03-09 [TCN, MLB.TV]\n", "2016-03-10 [TCN, MLBN, MLB.TV]\n", "2016-03-11 []\n", "2016-03-12 [CSN, MLB.TV]\n", "2016-03-13 [MLB.TV]\n", "2016-03-14 []\n", "2016-03-15 []\n", "2016-03-17 [TCN, MLB.TV]\n", "2016-03-18 [TCN, MLB.TV]\n", "2016-03-19 [MLB.TV]\n", "2016-03-20 [CSN, MLB.TV]\n", "2016-03-21 []\n", "2016-03-22 [TCN, MLB.TV]\n", "2016-03-23 []\n", "2016-03-24 [MLB.TV]\n", "2016-03-25 [CSN, MLB.TV]\n", "2016-03-26 [CSN, MLB.TV]\n", "2016-03-27 [MLB.TV]\n", "2016-03-28 []\n", "2016-03-29 [TCN, MLBN, MLB.TV]\n", "2016-03-30 [TCN, MLB.TV]\n", "2016-03-31 [TCN, MLB.TV]\n", "2016-04-01 [TCN, MLB.TV]\n", "2016-04-02 [TCN, MLB.TV]\n", "2016-04-04 [CSN]\n", "2016-04-06 [CSN, ESPN2]\n", "2016-04-07 [CSN]\n", " ... \n", "2016-08-31 [CSN]\n", "2016-09-02 [CSN]\n", "2016-09-03 [CSN]\n", "2016-09-04 [CSN]\n", "2016-09-05 [CSN]\n", "2016-09-06 [CSN]\n", "2016-09-07 [CSN]\n", "2016-09-08 [CSN]\n", "2016-09-09 [CSN]\n", "2016-09-10 [CSN]\n", "2016-09-11 [CSN]\n", "2016-09-12 [CSN]\n", "2016-09-13 [CSN]\n", "2016-09-14 [CSN]\n", "2016-09-15 [CSN]\n", "2016-09-16 [CSN]\n", "2016-09-17 [CSN]\n", "2016-09-18 [CSN]\n", "2016-09-20 [CSN]\n", "2016-09-21 [CSN]\n", "2016-09-22 [CSN]\n", "2016-09-23 [CSN]\n", "2016-09-24 [CSN]\n", "2016-09-25 [CSN]\n", "2016-09-27 [CSN]\n", "2016-09-28 [CSN]\n", "2016-09-29 [CSN]\n", "2016-09-30 [CSN]\n", "2016-10-01 [CSN]\n", "2016-10-02 [CSN]\n", "Name: DESCRIPTION, dtype: object" ] }, "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stations_series = schedule.DESCRIPTION.apply(lambda d: tv_stations_from_description(d))\n", "stations_series" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Double check the `set` of stations from that `Series`." ] }, { "cell_type": "code", "execution_count": 129, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "{'CSN', 'ESPN2', 'MLB.TV', 'MLBN', 'NBC 10', 'TCN'}" ] }, "execution_count": 129, "metadata": {}, "output_type": "execute_result" } ], "source": [ "set([station for stations in stations_series.values for station in stations])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The 190 Phillies games are broadcast on 6 television channels. Unfortunately only 1 of those 6 stations are available without a cable television subscription. This means that I can only watch games on NBC.\n", "\n", "## The Phillies national television broadcast schedule\n", "\n", "Filtering the `DESCRIPTION` column to national television broadcast stations yields only the games which I can watch over the air with my [HD antenna](http://amzn.to/1r5eZmQ)." ] }, { "cell_type": "code", "execution_count": 117, "metadata": { "collapsed": false }, "outputs": [ { "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", "
START TIMESUBJECTLOCATIONDESCRIPTION
START DATE
2016-04-1103:05 PMPadres at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
2016-06-0307:05 PMBrewers at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
2016-06-1007:05 PMPhillies at NationalsNationals Park - WashingtonLocal TV: NBC 10
2016-06-1707:05 PMD-backs at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
2016-06-2301:10 PMPhillies at TwinsTarget Field - MinneapolisLocal TV: NBC 10
2016-07-1507:05 PMMets at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
2016-07-1607:05 PMMets at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
2016-07-2207:05 PMPhillies at PiratesPNC Park - PittsburghLocal TV: NBC 10
2016-07-3007:10 PMPhillies at BravesTurner Field - AtlantaLocal TV: NBC 10
2016-08-0401:05 PMGiants at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
\n", "
" ], "text/plain": [ " START TIME SUBJECT \\\n", "START DATE \n", "2016-04-11 03:05 PM Padres at Phillies \n", "2016-06-03 07:05 PM Brewers at Phillies \n", "2016-06-10 07:05 PM Phillies at Nationals \n", "2016-06-17 07:05 PM D-backs at Phillies \n", "2016-06-23 01:10 PM Phillies at Twins \n", "2016-07-15 07:05 PM Mets at Phillies \n", "2016-07-16 07:05 PM Mets at Phillies \n", "2016-07-22 07:05 PM Phillies at Pirates \n", "2016-07-30 07:10 PM Phillies at Braves \n", "2016-08-04 01:05 PM Giants at Phillies \n", "\n", " LOCATION DESCRIPTION \n", "START DATE \n", "2016-04-11 Citizens Bank Park - Philadelphia Local TV: NBC 10 \n", "2016-06-03 Citizens Bank Park - Philadelphia Local TV: NBC 10 \n", "2016-06-10 Nationals Park - Washington Local TV: NBC 10 \n", "2016-06-17 Citizens Bank Park - Philadelphia Local TV: NBC 10 \n", "2016-06-23 Target Field - Minneapolis Local TV: NBC 10 \n", "2016-07-15 Citizens Bank Park - Philadelphia Local TV: NBC 10 \n", "2016-07-16 Citizens Bank Park - Philadelphia Local TV: NBC 10 \n", "2016-07-22 PNC Park - Pittsburgh Local TV: NBC 10 \n", "2016-07-30 Turner Field - Atlanta Local TV: NBC 10 \n", "2016-08-04 Citizens Bank Park - Philadelphia Local TV: NBC 10 " ] }, "execution_count": 117, "metadata": {}, "output_type": "execute_result" } ], "source": [ "national_broadcast_schedule = schedule[schedule.DESCRIPTION.str.contains(\"NBC 10\") == True]\n", "national_broadcast_schedule" ] }, { "cell_type": "code", "execution_count": 118, "metadata": { "collapsed": false }, "outputs": [ { "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", "
START TIMESUBJECTLOCATIONDESCRIPTION
count10101010
unique5951
top07:05 PMMets at PhilliesCitizens Bank Park - PhiladelphiaLocal TV: NBC 10
freq62610
\n", "
" ], "text/plain": [ " START TIME SUBJECT LOCATION \\\n", "count 10 10 10 \n", "unique 5 9 5 \n", "top 07:05 PM Mets at Phillies Citizens Bank Park - Philadelphia \n", "freq 6 2 6 \n", "\n", " DESCRIPTION \n", "count 10 \n", "unique 1 \n", "top Local TV: NBC 10 \n", "freq 10 " ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "national_broadcast_schedule.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This means that I have the possibility to watch 10 out of 190 Phillies games this season which is roughly 5%." ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }