30 Days Of Python πŸ‘¨β€πŸ’» - Day 27 - ML And Data Science

This article is a part of a 30 day Python challenge series. You can find the links to all the previous posts of this series here:
It is time to dig into some real Machine Learning and Data Science coding concepts. Today I mainly focused on getting started with the Jupyter Notebook workflow and creating a basic project to understand how it works. Finally I searched for some data set and then followed the basic principles of Machine Learning on it to generate useful information from it. I will also share the notebook I created. The great thing about Jupyter Notebooks it can be literally organized like a blog post or article along with the interactive code, data and other information.
 

Working with Jupyter Notebooks

 
I would like to provide a reference to some cool resources to understand the Jupyter Notebook interface, installation guide and its workflow overview.
  • Jupyter Notebook Tutorial Video
  • Installation guideline - (It is recommended to install it using Anaconda toolkit as it comes with a lot of useful tools.) 
Since I am a Windows user, I would like to provide a quick  tip.
 
In Windows, open Anaconda Prompt from the start menu, navigate to the directory where you want to create Jupyter projects, then run the command Jupyter notebook. It will open up the notebook in the browser.
 
As per the basic steps of Machine Learning and Data Science, we shall be creating the project and create a readable notebook that documents the entire process which can then be shared with anyone.
 

Basics of Data Science and ML using Netflix Shows project

 
The basic steps of ML and Data Science are,
  • Importing data from some source
  • Cleaning up the data to remove any irrelevant data if needed
  • Splitting up data into Training Set and Test Set.
  • Creating a model or an algorithm or a function
  • Checking the output
  • Improve and repeat the above steps
We shall explore the first two steps in this basic project
 

Importing data and manipulation

 
The first and the most important thing for Machine Learning and Data Science is the data itself. To obtain good meaningful conclusions, we must have good data sets. This input data can be collected in a number of ways - from databases, by scraping websites, public APIs or public shared data sets.
 
Kaggle is a popular website among Machine Learning and Data Science enthusiasts where tons of publicly shared data sets can be found.
 
I decided to search for a Netflix Shows data set and found this one from Kaggle - https://www.kaggle.com/shivamb/netflix-shows. It contains the data in a CSV format which will be used for this project. After downloading the file, it can be placed in the root directory of the project. I have named it netflix_titles.csv
 
Since this data is in a kind of tabular format meaning it is arranged in rows and columns, pandas is a great open-source library to process this kind of data and analyze it. It comes along with the Anaconda toolkit, so it can be used directly in the notebook.
  1. import pandas as pd    
  2. data_frame = pd.read_csv('netflix_titles.csv')    
  3. data_frame.head(10) # show first 10 results    
  4. # prints the data frame in as a table    
  5.   
  6. <div class=“table-wrapper”>  
  7.     <table border=“1” class=“dataframe”>  
  8.         <thead>  
  9.             <tr style=“text-align: right;”>  
  10.                 <th></th>  
  11.                 <th>show_id</th>  
  12.                 <th>type</th>  
  13.                 <th>title</th>  
  14.                 <th>director</th>  
  15.                 <th>cast</th>  
  16.                 <th>country</th>  
  17.                 <th>date_added</th>  
  18.                 <th>release_year</th>  
  19.                 <th>rating</th>  
  20.                 <th>duration</th>  
  21.                 <th>listed_in</th>  
  22.                 <th>description</th>  
  23.             </tr>  
  24.         </thead>  
  25.         <tbody>  
  26.             <tr>  
  27.                 <th>0</th>  
  28.                 <td>81145628</td>  
  29.                 <td>Movie</td>  
  30.                 <td>Norm of the North: King Sized Adventure</td>  
  31.                 <td>Richard Finn, Tim Maltby</td>  
  32.                 <td>Alan Marriott, Andrew Toth, Brian Dobson, Cole…</td>  
  33.                 <td>United States, India, South Korea, China</td>  
  34.                 <td>September 9, 2019</td>  
  35.                 <td>2019</td>  
  36.                 <td>TV-PG</td>  
  37.                 <td>90 min</td>  
  38.                 <td>Children & Family Movies, Comedies</td>  
  39.                 <td>Before planning an awesome wedding for his gra…</td>  
  40.             </tr>  
  41.             <tr>  
  42.                 <th>1</th>  
  43.                 <td>80117401</td>  
  44.                 <td>Movie</td>  
  45.                 <td>Jandino: Whatever it Takes</td>  
  46.                 <td>NaN</td>  
  47.                 <td>Jandino Asporaat</td>  
  48.                 <td>United Kingdom</td>  
  49.                 <td>September 9, 2016</td>  
  50.                 <td>2016</td>  
  51.                 <td>TV-MA</td>  
  52.                 <td>94 min</td>  
  53.                 <td>Stand-Up Comedy</td>  
  54.                 <td>Jandino Asporaat riffs on the challenges of ra…</td>  
  55.             </tr>  
  56.             <tr>  
  57.                 <th>2</th>  
  58.                 <td>70234439</td>  
  59.                 <td>TV Show</td>  
  60.                 <td>Transformers Prime</td>  
  61.                 <td>NaN</td>  
  62.                 <td>Peter Cullen, Sumalee Montano, Frank Welker, J…</td>  
  63.                 <td>United States</td>  
  64.                 <td>September 8, 2018</td>  
  65.                 <td>2013</td>  
  66.                 <td>TV-Y7-FV</td>  
  67.                 <td>1 Season</td>  
  68.                 <td>Kids’ TV</td>  
  69.                 <td>With the help of three human allies, the Autob…</td>  
  70.             </tr>  
  71.             <tr>  
  72.                 <th>3</th>  
  73.                 <td>80058654</td>  
  74.                 <td>TV Show</td>  
  75.                 <td>Transformers: Robots in Disguise</td>  
  76.                 <td>NaN</td>  
  77.                 <td>Will Friedle, Darren Criss, Constance Zimmer, …</td>  
  78.                 <td>United States</td>  
  79.                 <td>September 8, 2018</td>  
  80.                 <td>2016</td>  
  81.                 <td>TV-Y7</td>  
  82.                 <td>1 Season</td>  
  83.                 <td>Kids’ TV</td>  
  84.                 <td>When a prison ship crash unleashes hundreds of…</td>  
  85.             </tr>  
  86.             <tr>  
  87.                 <th>4</th>  
  88.                 <td>80125979</td>  
  89.                 <td>Movie</td>  
  90.                 <td>#realityhigh</td>  
  91.                 <td>Fernando Lebrija</td>  
  92.                 <td>Nesta Cooper, Kate Walsh, John Michael Higgins…</td>  
  93.                 <td>United States</td>  
  94.                 <td>September 8, 2017</td>  
  95.                 <td>2017</td>  
  96.                 <td>TV-14</td>  
  97.                 <td>99 min</td>  
  98.                 <td>Comedies</td>  
  99.                 <td>When nerdy high schooler Dani finally attracts…</td>  
  100.             </tr>  
  101.             <tr>  
  102.                 <th>5</th>  
  103.                 <td>80163890</td>  
  104.                 <td>TV Show</td>  
  105.                 <td>Apaches</td>  
  106.                 <td>NaN</td>  
  107.                 <td>Alberto Ammann, Eloy Azorín, Verónica Echegui,…</td>  
  108.                 <td>Spain</td>  
  109.                 <td>September 8, 2017</td>  
  110.                 <td>2016</td>  
  111.                 <td>TV-MA</td>  
  112.                 <td>1 Season</td>  
  113.                 <td>Crime TV Shows, International TV Shows, Spanis…</td>  
  114.                 <td>A young journalist is forced into a life of cr…</td>  
  115.             </tr>  
  116.             <tr>  
  117.                 <th>6</th>  
  118.                 <td>70304989</td>  
  119.                 <td>Movie</td>  
  120.                 <td>Automata</td>  
  121.                 <td>Gabe Ibáñez</td>  
  122.                 <td>Antonio Banderas, Dylan McDermott, Melanie Gri…</td>  
  123.                 <td>Bulgaria, United States, Spain, Canada</td>  
  124.                 <td>September 8, 2017</td>  
  125.                 <td>2014</td>  
  126.                 <td>R</td>  
  127.                 <td>110 min</td>  
  128.                 <td>International Movies, Sci-Fi & Fantasy, Thrillers</td>  
  129.                 <td>In a dystopian future, an insurance adjuster f…</td>  
  130.             </tr>  
  131.             <tr>  
  132.                 <th>7</th>  
  133.                 <td>80164077</td>  
  134.                 <td>Movie</td>  
  135.                 <td>Fabrizio Copano: Solo pienso en mi</td>  
  136.                 <td>Rodrigo Toro, Francisco Schultz</td>  
  137.                 <td>Fabrizio Copano</td>  
  138.                 <td>Chile</td>  
  139.                 <td>September 8, 2017</td>  
  140.                 <td>2017</td>  
  141.                 <td>TV-MA</td>  
  142.                 <td>60 min</td>  
  143.                 <td>Stand-Up Comedy</td>  
  144.                 <td>Fabrizio Copano takes audience participation t…</td>  
  145.             </tr>  
  146.             <tr>  
  147.                 <th>8</th>  
  148.                 <td>80117902</td>  
  149.                 <td>TV Show</td>  
  150.                 <td>Fire Chasers</td>  
  151.                 <td>NaN</td>  
  152.                 <td>NaN</td>  
  153.                 <td>United States</td>  
  154.                 <td>September 8, 2017</td>  
  155.                 <td>2017</td>  
  156.                 <td>TV-MA</td>  
  157.                 <td>1 Season</td>  
  158.                 <td>Docuseries, Science & Nature TV</td>  
  159.                 <td>As California’s 2016 fire season rages, brave …</td>  
  160.             </tr>  
  161.             <tr>  
  162.                 <th>9</th>  
  163.                 <td>70304990</td>  
  164.                 <td>Movie</td>  
  165.                 <td>Good People</td>  
  166.                 <td>Henrik Ruben Genz</td>  
  167.                 <td>James Franco, Kate Hudson, Tom Wilkinson, Omar…</td>  
  168.                 <td>United States, United Kingdom, Denmark, Sweden</td>  
  169.                 <td>September 8, 2017</td>  
  170.                 <td>2014</td>  
  171.                 <td>R</td>  
  172.                 <td>90 min</td>  
  173.                 <td>Action & Adventure, Thrillers</td>  
  174.                 <td>A struggling couple can’t believe their luck w…</td>  
  175.             </tr>  
  176.         </tbody>  
  177.     </table>  
  178. </div>    
  179.   
  180. data_frame.info()    
  181. # shows information about column data types    
  182.   
  183. <class 'pandas.core.frame.DataFrame'>    
  184. RangeIndex: 6234 entries, 0 to 6233    
  185. Data columns (total 12 columns):    
  186.  #   Column        Non-Null Count  Dtype     
  187. ---  ------        --------------  -----     
  188.  0   show_id       6234 non-null   int64     
  189.  1   type          6234 non-null   object    
  190.  2   title         6234 non-null   object    
  191.  3   director      4265 non-null   object    
  192.  4   cast          5664 non-null   object    
  193.  5   country       5758 non-null   object    
  194.  6   date_added    6223 non-null   object    
  195.  7   release_year  6234 non-null   int64     
  196.  8   rating        6224 non-null   object    
  197.  9   duration      6234 non-null   object    
  198.  10  listed_in     6234 non-null   object    
  199.  11  description   6234 non-null   object    
  200. dtypes: int64(2), object(10)    
  201. memory usage: 584.6+ KB    
  202.    
  203. data_frame.shape    
  204. # provides information of rows and columns as a tuple    
  205.    
  206. (6234, 12)   
  207. data_frame.describe()    
  208. # shows some basic description    
  209.    
  210.   
  211.     <div class="table-wrapper">  
  212.         <table border="1" class="dataframe">  
  213.             <thead>  
  214.                 <tr style="text-align: right;">  
  215.                     <th></th>  
  216.                     <th>show_id</th>  
  217.                     <th>release_year</th>  
  218.                 </tr>  
  219.             </thead>  
  220.             <tbody>  
  221.                 <tr>  
  222.                     <th>count</th>  
  223.                     <td>6.234000e+03</td>  
  224.                     <td>6234.00000</td>  
  225.                 </tr>  
  226.                 <tr>  
  227.                     <th>mean</th>  
  228.                     <td>7.670368e+07</td>  
  229.                     <td>2013.35932</td>  
  230.                 </tr>  
  231.                 <tr>  
  232.                     <th>std</th>  
  233.                     <td>1.094296e+07</td>  
  234.                     <td>8.81162</td>  
  235.                 </tr>  
  236.                 <tr>  
  237.                     <th>min</th>  
  238.                     <td>2.477470e+05</td>  
  239.                     <td>1925.00000</td>  
  240.                 </tr>  
  241.                 <tr>  
  242.                     <th>25%</th>  
  243.                     <td>8.003580e+07</td>  
  244.                     <td>2013.00000</td>  
  245.                 </tr>  
  246.                 <tr>  
  247.                     <th>50%</th>  
  248.                     <td>8.016337e+07</td>  
  249.                     <td>2016.00000</td>  
  250.                 </tr>  
  251.                 <tr>  
  252.                     <th>75%</th>  
  253.                     <td>8.024489e+07</td>  
  254.                     <td>2018.00000</td>  
  255.                 </tr>  
  256.                 <tr>  
  257.                     <th>max</th>  
  258.                     <td>8.123573e+07</td>  
  259.                     <td>2020.00000</td>  
  260.                 </tr>  
  261.             </tbody>  
  262.         </table>  
  263.     </div>    
  264.   
  265. data_frame['title'].head() # lists a specific column data with first 5 entries (head)    
  266.    
  267. 0    Norm of the North: King Sized Adventure    
  268. 1                 Jandino: Whatever it Takes    
  269. 2                         Transformers Prime    
  270. 3           Transformers: Robots in Disguise    
  271. 4                               #realityhigh    
  272. Name: title, dtype: object    
  273.   
  274. # Filtering Data    
  275. data_frame[data_frame['country'] == 'India'].head()    
  276.    
  277.   
  278.     <div class="table-wrapper">  
  279.         <table border="1" class="dataframe">  
  280.             <thead>  
  281.                 <tr style="text-align: right;">  
  282.                     <th></th>  
  283.                     <th>show_id</th>  
  284.                     <th>type</th>  
  285.                     <th>title</th>  
  286.                     <th>director</th>  
  287.                     <th>cast</th>  
  288.                     <th>country</th>  
  289.                     <th>date_added</th>  
  290.                     <th>release_year</th>  
  291.                     <th>rating</th>  
  292.                     <th>duration</th>  
  293.                     <th>listed_in</th>  
  294.                     <th>description</th>  
  295.                 </tr>  
  296.             </thead>  
  297.             <tbody>  
  298.                 <tr>  
  299.                     <th>35</th>  
  300.                     <td>81154455</td>  
  301.                     <td>Movie</td>  
  302.                     <td>Article 15</td>  
  303.                     <td>Anubhav Sinha</td>  
  304.                     <td>Ayushmann Khurrana, Nassar, Manoj Pahwa, Kumud...</td>  
  305.                     <td>India</td>  
  306.                     <td>September 6, 2019</td>  
  307.                     <td>2019</td>  
  308.                     <td>TV-MA</td>  
  309.                     <td>125 min</td>  
  310.                     <td>Dramas, International Movies, Thrillers</td>  
  311.                     <td>The grim realities of caste discrimination com...</td>  
  312.                 </tr>  
  313.                 <tr>  
  314.                     <th>37</th>  
  315.                     <td>81052275</td>  
  316.                     <td>Movie</td>  
  317.                     <td>Ee Nagaraniki Emaindi</td>  
  318.                     <td>Tharun Bhascker</td>  
  319.                     <td>Vishwaksen Naidu, Sushanth Reddy, Abhinav Goma...</td>  
  320.                     <td>India</td>  
  321.                     <td>September 6, 2019</td>  
  322.                     <td>2018</td>  
  323.                     <td>TV-14</td>  
  324.                     <td>133 min</td>  
  325.                     <td>Comedies, International Movies</td>  
  326.                     <td>In Goa and in desperate need of cash, four chi...</td>  
  327.                 </tr>  
  328.                 <tr>  
  329.                     <th>41</th>  
  330.                     <td>70303496</td>  
  331.                     <td>Movie</td>  
  332.                     <td>PK</td>  
  333.                     <td>Rajkumar Hirani</td>  
  334.                     <td>Aamir Khan, Anuskha Sharma, Sanjay Dutt, Saura...</td>  
  335.                     <td>India</td>  
  336.                     <td>September 6, 2018</td>  
  337.                     <td>2014</td>  
  338.                     <td>TV-14</td>  
  339.                     <td>146 min</td>  
  340.                     <td>Comedies, Dramas, International Movies</td>  
  341.                     <td>Aamir Khan teams with director Rajkumar Hirani...</td>  
  342.                 </tr>  
  343.                 <tr>  
  344.                     <th>58</th>  
  345.                     <td>81155784</td>  
  346.                     <td>Movie</td>  
  347.                     <td>Watchman</td>  
  348.                     <td>A. L. Vijay</td>  
  349.                     <td>G.V. Prakash Kumar, Samyuktha Hegde, Suman, Ra...</td>  
  350.                     <td>India</td>  
  351.                     <td>September 4, 2019</td>  
  352.                     <td>2019</td>  
  353.                     <td>TV-14</td>  
  354.                     <td>93 min</td>  
  355.                     <td>Comedies, Dramas, International Movies</td>  
  356.                     <td>Rushing to pay off a loan shark, a young man b...</td>  
  357.                 </tr>  
  358.                 <tr>  
  359.                     <th>99</th>  
  360.                     <td>80225885</td>  
  361.                     <td>TV Show</td>  
  362.                     <td>Bard of Blood</td>  
  363.                     <td>NaN</td>  
  364.                     <td>Emraan Hashmi, Viineet Kumar, Sobhita Dhulipal...</td>  
  365.                     <td>India</td>  
  366.                     <td>September 27, 2019</td>  
  367.                     <td>2019</td>  
  368.                     <td>TV-MA</td>  
  369.                     <td>1 Season</td>  
  370.                     <td>International TV Shows, TV Action & Adventure,...</td>  
  371.                     <td>Years after a disastrous job in Balochistan, a...</td>  
  372.                 </tr>  
  373.             </tbody>  
  374.         </table>  
  375.     </div>    
  376.  
  377. # Sorting Data    
  378. data_frame.sort_values('release_year', ascending=False).head()    
  379.    
  380.   
  381.     <div class="table-wrapper">  
  382.         <table border="1" class="dataframe">  
  383.             <thead>  
  384.                 <tr style="text-align: right;">  
  385.                     <th></th>  
  386.                     <th>show_id</th>  
  387.                     <th>type</th>  
  388.                     <th>title</th>  
  389.                     <th>director</th>  
  390.                     <th>cast</th>  
  391.                     <th>country</th>  
  392.                     <th>date_added</th>  
  393.                     <th>release_year</th>  
  394.                     <th>rating</th>  
  395.                     <th>duration</th>  
  396.                     <th>listed_in</th>  
  397.                     <th>description</th>  
  398.                 </tr>  
  399.             </thead>  
  400.             <tbody>  
  401.                 <tr>  
  402.                     <th>3467</th>  
  403.                     <td>81011449</td>  
  404.                     <td>TV Show</td>  
  405.                     <td>Medical Police</td>  
  406.                     <td>NaN</td>  
  407.                     <td>Erinn Hayes, Rob Huebel, Malin Akerman, Rob Co...</td>  
  408.                     <td>United States</td>  
  409.                     <td>January 10, 2020</td>  
  410.                     <td>2020</td>  
  411.                     <td>TV-MA</td>  
  412.                     <td>1 Season</td>  
  413.                     <td>Crime TV Shows, TV Action & Adventure, TV Come...</td>  
  414.                     <td>Doctors Owen Maestro and Lola Spratt leave Chi...</td>  
  415.                 </tr>  
  416.                 <tr>  
  417.                     <th>3249</th>  
  418.                     <td>81006825</td>  
  419.                     <td>Movie</td>  
  420.                     <td>All the Freckles in the World</td>  
  421.                     <td>Yibrán Asuad</td>  
  422.                     <td>Hánssel Casillas, Loreto Peralta, Andrea Sutto...</td>  
  423.                     <td>Mexico</td>  
  424.                     <td>January 3, 2020</td>  
  425.                     <td>2020</td>  
  426.                     <td>TV-14</td>  
  427.                     <td>90 min</td>  
  428.                     <td>Comedies, International Movies, Romantic Movies</td>  
  429.                     <td>Thirteen-year-old José Miguel is immune to 199...</td>  
  430.                 </tr>  
  431.                 <tr>  
  432.                     <th>3220</th>  
  433.                     <td>80997687</td>  
  434.                     <td>TV Show</td>  
  435.                     <td>Dracula</td>  
  436.                     <td>NaN</td>  
  437.                     <td>Claes Bang, Dolly Wells, John Heffernan</td>  
  438.                     <td>United Kingdom</td>  
  439.                     <td>January 4, 2020</td>  
  440.                     <td>2020</td>  
  441.                     <td>TV-14</td>  
  442.                     <td>1 Season</td>  
  443.                     <td>British TV Shows, International TV Shows, TV D...</td>  
  444.                     <td>The Count Dracula legend transforms with new t...</td>  
  445.                 </tr>  
  446.                 <tr>  
  447.                     <th>3427</th>  
  448.                     <td>81060049</td>  
  449.                     <td>Movie</td>  
  450.                     <td>Leslie Jones: Time Machine</td>  
  451.                     <td>David Benioff, D.B. Weiss</td>  
  452.                     <td>Leslie Jones</td>  
  453.                     <td>United States</td>  
  454.                     <td>January 14, 2020</td>  
  455.                     <td>2020</td>  
  456.                     <td>TV-MA</td>  
  457.                     <td>66 min</td>  
  458.                     <td>Stand-Up Comedy</td>  
  459.                     <td>From trying to seduce Prince to battling sleep...</td>  
  460.                 </tr>  
  461.                 <tr>  
  462.                     <th>3436</th>  
  463.                     <td>80239306</td>  
  464.                     <td>TV Show</td>  
  465.                     <td>The Healing Powers of Dude</td>  
  466.                     <td>NaN</td>  
  467.                     <td>Jace Chapman, Larisa Oleynik, Tom Everett Scot...</td>  
  468.                     <td>NaN</td>  
  469.                     <td>January 13, 2020</td>  
  470.                     <td>2020</td>  
  471.                     <td>TV-G</td>  
  472.                     <td>1 Season</td>  
  473.                     <td>Kids' TV, TV Comedies, TV Dramas</td>  
  474.                     <td>When an 11-year-old boy with social anxiety di...</td>  
  475.                 </tr>  
  476.             </tbody>  
  477.         </table>  
  478.     </div>    
This is a great cheat-sheet for Data Science with Python which lists all the commonly used Pandas methods and properties along with other libraries for data science as well.
 

Cleaning Data

 
The next step is cleaning up data and removing any kinds of information that is not required for the analysis.
 
Let’s consider an example use case where we want to find which Netflix comedy movies and shows that are suitable for all ages (TV-G rating).
  1. # Let's select the relevant columns for analysis    
  2. df_shows = pd.DataFrame(data_frame, columns=['title','rating''listed_in'])    
  3. # filter comedy shows    
  4. df_comedy_shows = df_shows[df_shows['listed_in'].str.contains('Comed')]    
  5. df_comedy_shows.head()    
  6.    
  7. <div class="table-wrapper">    
  8. <table border="1" class="dataframe">    
  9.   <thead>    
  10.     <tr style="text-align: right;">    
  11.       <th></th>    
  12.       <th>title</th>    
  13.       <th>rating</th>    
  14.       <th>listed_in</th>    
  15.     </tr>    
  16.   </thead>    
  17.   <tbody>    
  18.     <tr>    
  19.       <th>0</th>    
  20.       <td>Norm of the North: King Sized Adventure</td>    
  21.       <td>TV-PG</td>    
  22.       <td>Children & Family Movies, Comedies</td>    
  23.     </tr>    
  24.     <tr>    
  25.       <th>1</th>    
  26.       <td>Jandino: Whatever it Takes</td>    
  27.       <td>TV-MA</td>    
  28.       <td>Stand-Up Comedy</td>    
  29.     </tr>    
  30.     <tr>    
  31.       <th>4</th>    
  32.       <td>#realityhigh</td>    
  33.       <td>TV-14</td>    
  34.       <td>Comedies</td>    
  35.     </tr>    
  36.     <tr>    
  37.       <th>7</th>    
  38.       <td>Fabrizio Copano: Solo pienso en mi</td>    
  39.       <td>TV-MA</td>    
  40.       <td>Stand-Up Comedy</td>    
  41.     </tr>    
  42.     <tr>    
  43.       <th>10</th>    
  44.       <td>Joaquín Reyes: Una y no más</td>    
  45.       <td>TV-MA</td>    
  46.       <td>Stand-Up Comedy</td>    
  47.     </tr>    
  48.   </tbody>    
  49. </table>    
  50. </div>    
  51.  
  52. # filter shows for all ages    
  53. df_all_ages = df_comedy_shows[df_comedy_shows['rating']=='TV-G']    
  54. df_all_ages.head()    
  55.    
  56. <div class="table-wrapper">    
  57. <table border="1" class="dataframe">    
  58.   <thead>    
  59.     <tr style="text-align: right;">    
  60.       <th></th>    
  61.       <th>title</th>    
  62.       <th>rating</th>    
  63.       <th>listed_in</th>    
  64.     </tr>    
  65.   </thead>    
  66.   <tbody>    
  67.     <tr>    
  68.       <th>1034</th>    
  69.       <td>Luccas Neto in: Summer Camp</td>    
  70.       <td>TV-G</td>    
  71.       <td>Children & Family Movies, Comedies</td>    
  72.     </tr>    
  73.     <tr>    
  74.       <th>1043</th>    
  75.       <td>A Holiday Engagement</td>    
  76.       <td>TV-G</td>    
  77.       <td>Children & Family Movies, Comedies, Romantic M...</td>    
  78.     </tr>    
  79.     <tr>    
  80.       <th>1205</th>    
  81.       <td>A Fairly Odd Summer</td>    
  82.       <td>TV-G</td>    
  83.       <td>Children & Family Movies, Comedies</td>    
  84.     </tr>    
  85.     <tr>    
  86.       <th>1206</th>    
  87.       <td>Bella and the Bulldogs</td>    
  88.       <td>TV-G</td>    
  89.       <td>Kids' TV, TV Comedies</td>    
  90.     </tr>    
  91.     <tr>    
  92.       <th>1211</th>    
  93.       <td>Jinxed</td>    
  94.       <td>TV-G</td>    
  95.       <td>Children & Family Movies, Comedies</td>    
  96.     </tr>    
  97.   </tbody>    
  98. </table>    
  99. </div>   
The Github repository for this notebook can be found here.
 
Resources
That’s all for today’s post. Tomorrow I will continue exploring more of the other steps of machine learning and data science and perform a visual analysis of data by building charts and diagrams along with creating machine learning models.
 
Have a great one!