CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
DanielBarnes18

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: DanielBarnes18/IBM-Data-Science-Professional-Certificate
Path: blob/main/10. Applied Data Science Capstone/01. Data Collection/01. Data Collection - Web Scraping.ipynb
Views: 4598
Kernel: Python 3.8
cognitiveclass.ai logo

Space X Falcon 9 First Stage Landing Prediction

Web scraping Falcon 9 and Falcon Heavy Launches Records from Wikipedia

Estimated time needed: 40 minutes

In this lab, you will be performing web scraping to collect Falcon 9 historical launch records from a Wikipedia page titled List of Falcon 9 and Falcon Heavy launches

https://en.wikipedia.org/wiki/List_of_Falcon_9_and_Falcon_Heavy_launches

Falcon 9 first stage will land successfully

Several examples of an unsuccessful landing are shown here:

More specifically, the launch records are stored in a HTML table shown below:

Objectives

Web scrap Falcon 9 launch records with BeautifulSoup:

  • Extract a Falcon 9 launch records HTML table from Wikipedia

  • Parse the table and convert it into a Pandas data frame

First let's import required packages for this lab

!pip3 install beautifulsoup4 !pip3 install requests
Requirement already satisfied: beautifulsoup4 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (4.9.3) Requirement already satisfied: soupsieve>1.2 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (from beautifulsoup4) (2.2.1) Requirement already satisfied: requests in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (2.25.1) Requirement already satisfied: chardet<5,>=3.0.2 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (from requests) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (from requests) (2021.10.8) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (from requests) (1.26.6) Requirement already satisfied: idna<3,>=2.5 in /opt/conda/envs/Python-3.8-main/lib/python3.8/site-packages (from requests) (2.8)
import sys import requests from bs4 import BeautifulSoup import re import unicodedata import pandas as pd

and we will provide some helper functions for you to process web scraped HTML table

def date_time(table_cells): """ This function returns the data and time from the HTML table cell Input: the element of a table data cell extracts extra row """ return [data_time.strip() for data_time in list(table_cells.strings)][0:2] def booster_version(table_cells): """ This function returns the booster version from the HTML table cell Input: the element of a table data cell extracts extra row """ out=''.join([booster_version for i,booster_version in enumerate( table_cells.strings) if i%2==0][0:-1]) return out def landing_status(table_cells): """ This function returns the landing status from the HTML table cell Input: the element of a table data cell extracts extra row """ out=[i for i in table_cells.strings][0] return out def get_mass(table_cells): mass=unicodedata.normalize("NFKD", table_cells.text).strip() if mass: mass.find("kg") new_mass=mass[0:mass.find("kg")+2] else: new_mass=0 return new_mass def extract_column_from_header(row): """ This function returns the landing status from the HTML table cell Input: the element of a table data cell extracts extra row """ if (row.br): row.br.extract() if row.a: row.a.extract() if row.sup: row.sup.extract() colunm_name = ' '.join(row.contents) # Filter the digit and empty names if not(colunm_name.strip().isdigit()): colunm_name = colunm_name.strip() return colunm_name

To keep the lab tasks consistent, you will be asked to scrape the data from a snapshot of the List of Falcon 9 and Falcon Heavy launches Wikipage updated on 9th June 2021

static_url = "https://en.wikipedia.org/w/index.php?title=List_of_Falcon_9_and_Falcon_Heavy_launches&oldid=1027686922"

Next, request the HTML page from the above URL and get a response object

TASK 1: Request the Falcon9 Launch Wiki page from its URL

First, let's perform an HTTP GET method to request the Falcon9 Launch HTML page, as an HTTP response.

# use requests.get() method with the provided static_url response = requests.get(static_url) # assign the response to a object data = response.text

Create a BeautifulSoup object from the HTML response

# Use BeautifulSoup() to create a BeautifulSoup object from a response text content soup = BeautifulSoup(data, 'html5lib')

Print the page title to verify if the BeautifulSoup object was created properly

# Use soup.title attribute print(soup.title)
<title>List of Falcon 9 and Falcon Heavy launches - Wikipedia</title>

TASK 2: Extract all column/variable names from the HTML table header

Next, we want to collect all relevant column names from the HTML table header

Let's try to find all tables on the wiki page first. If you need to refresh your memory about BeautifulSoup, please check the external reference link towards the end of this lab

# Use the find_all function in the BeautifulSoup object, with element type `table` # Assign the result to a list called `html_tables` html_tables = soup.find_all('table')

Starting from the third table is our target table contains the actual launch records.

# Let's print the third table and check its content first_launch_table = html_tables[2] print(first_launch_table)
<table class="wikitable plainrowheaders collapsible" style="width: 100%;"> <tbody><tr> <th scope="col">Flight No. </th> <th scope="col">Date and<br/>time (<a href="/wiki/Coordinated_Universal_Time" title="Coordinated Universal Time">UTC</a>) </th> <th scope="col"><a href="/wiki/List_of_Falcon_9_first-stage_boosters" title="List of Falcon 9 first-stage boosters">Version,<br/>Booster</a> <sup class="reference" id="cite_ref-booster_11-0"><a href="#cite_note-booster-11">[b]</a></sup> </th> <th scope="col">Launch site </th> <th scope="col">Payload<sup class="reference" id="cite_ref-Dragon_12-0"><a href="#cite_note-Dragon-12">[c]</a></sup> </th> <th scope="col">Payload mass </th> <th scope="col">Orbit </th> <th scope="col">Customer </th> <th scope="col">Launch<br/>outcome </th> <th scope="col"><a href="/wiki/Falcon_9_first-stage_landing_tests" title="Falcon 9 first-stage landing tests">Booster<br/>landing</a> </th></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">1 </th> <td>4 June 2010,<br/>18:45 </td> <td><a href="/wiki/Falcon_9_v1.0" title="Falcon 9 v1.0">F9 v1.0</a><sup class="reference" id="cite_ref-MuskMay2012_13-0"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B0003.1<sup class="reference" id="cite_ref-block_numbers_14-0"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/Dragon_Spacecraft_Qualification_Unit" title="Dragon Spacecraft Qualification Unit">Dragon Spacecraft Qualification Unit</a> </td> <td> </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> </td> <td><a href="/wiki/SpaceX" title="SpaceX">SpaceX</a> </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success </td> <td class="table-failure" style="background: #ffbbbb; color: black; vertical-align: middle; text-align: center;">Failure<sup class="reference" id="cite_ref-ns20110930_15-0"><a href="#cite_note-ns20110930-15">[9]</a></sup><sup class="reference" id="cite_ref-16"><a href="#cite_note-16">[10]</a></sup><br/><small>(parachute)</small> </td></tr> <tr> <td colspan="9">First flight of Falcon 9 v1.0.<sup class="reference" id="cite_ref-sfn20100604_17-0"><a href="#cite_note-sfn20100604-17">[11]</a></sup> Used a boilerplate version of Dragon capsule which was not designed to separate from the second stage.<small>(<a href="#First_flight_of_Falcon_9">more details below</a>)</small> Attempted to recover the first stage by parachuting it into the ocean, but it burned up on reentry, before the parachutes even deployed.<sup class="reference" id="cite_ref-parachute_18-0"><a href="#cite_note-parachute-18">[12]</a></sup> </td></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">2 </th> <td>8 December 2010,<br/>15:43<sup class="reference" id="cite_ref-spaceflightnow_Clark_Launch_Report_19-0"><a href="#cite_note-spaceflightnow_Clark_Launch_Report-19">[13]</a></sup> </td> <td><a href="/wiki/Falcon_9_v1.0" title="Falcon 9 v1.0">F9 v1.0</a><sup class="reference" id="cite_ref-MuskMay2012_13-1"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B0004.1<sup class="reference" id="cite_ref-block_numbers_14-1"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/SpaceX_Dragon" title="SpaceX Dragon">Dragon</a> <a class="mw-redirect" href="/wiki/COTS_Demo_Flight_1" title="COTS Demo Flight 1">demo flight C1</a><br/>(Dragon C101) </td> <td> </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> (<a href="/wiki/International_Space_Station" title="International Space Station">ISS</a>) </td> <td><div class="plainlist"> <ul><li><a href="/wiki/NASA" title="NASA">NASA</a> (<a href="/wiki/Commercial_Orbital_Transportation_Services" title="Commercial Orbital Transportation Services">COTS</a>)</li> <li><a href="/wiki/National_Reconnaissance_Office" title="National Reconnaissance Office">NRO</a></li></ul> </div> </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success<sup class="reference" id="cite_ref-ns20110930_15-1"><a href="#cite_note-ns20110930-15">[9]</a></sup> </td> <td class="table-failure" style="background: #ffbbbb; color: black; vertical-align: middle; text-align: center;">Failure<sup class="reference" id="cite_ref-ns20110930_15-2"><a href="#cite_note-ns20110930-15">[9]</a></sup><sup class="reference" id="cite_ref-20"><a href="#cite_note-20">[14]</a></sup><br/><small>(parachute)</small> </td></tr> <tr> <td colspan="9">Maiden flight of <a class="mw-redirect" href="/wiki/Dragon_capsule" title="Dragon capsule">Dragon capsule</a>, consisting of over 3 hours of testing thruster maneuvering and reentry.<sup class="reference" id="cite_ref-spaceflightnow_Clark_unleashing_Dragon_21-0"><a href="#cite_note-spaceflightnow_Clark_unleashing_Dragon-21">[15]</a></sup> Attempted to recover the first stage by parachuting it into the ocean, but it disintegrated upon reentry, before the parachutes were deployed.<sup class="reference" id="cite_ref-parachute_18-1"><a href="#cite_note-parachute-18">[12]</a></sup> <small>(<a href="#COTS_demo_missions">more details below</a>)</small> It also included two <a href="/wiki/CubeSat" title="CubeSat">CubeSats</a>,<sup class="reference" id="cite_ref-NRO_Taps_Boeing_for_Next_Batch_of_CubeSats_22-0"><a href="#cite_note-NRO_Taps_Boeing_for_Next_Batch_of_CubeSats-22">[16]</a></sup> and a wheel of <a href="/wiki/Brou%C3%A8re" title="Brouère">Brouère</a> cheese. </td></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">3 </th> <td>22 May 2012,<br/>07:44<sup class="reference" id="cite_ref-BBC_new_era_23-0"><a href="#cite_note-BBC_new_era-23">[17]</a></sup> </td> <td><a href="/wiki/Falcon_9_v1.0" title="Falcon 9 v1.0">F9 v1.0</a><sup class="reference" id="cite_ref-MuskMay2012_13-2"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B0005.1<sup class="reference" id="cite_ref-block_numbers_14-2"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/SpaceX_Dragon" title="SpaceX Dragon">Dragon</a> <a class="mw-redirect" href="/wiki/Dragon_C2%2B" title="Dragon C2+">demo flight C2+</a><sup class="reference" id="cite_ref-C2_24-0"><a href="#cite_note-C2-24">[18]</a></sup><br/>(Dragon C102) </td> <td>525 kg (1,157 lb)<sup class="reference" id="cite_ref-25"><a href="#cite_note-25">[19]</a></sup> </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> (<a href="/wiki/International_Space_Station" title="International Space Station">ISS</a>) </td> <td><a href="/wiki/NASA" title="NASA">NASA</a> (<a href="/wiki/Commercial_Orbital_Transportation_Services" title="Commercial Orbital Transportation Services">COTS</a>) </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success<sup class="reference" id="cite_ref-26"><a href="#cite_note-26">[20]</a></sup> </td> <td class="table-noAttempt" style="background: #ececec; color: black; vertical-align: middle; white-space: nowrap; text-align: center;">No attempt </td></tr> <tr> <td colspan="9">Dragon spacecraft demonstrated a series of tests before it was allowed to approach the <a href="/wiki/International_Space_Station" title="International Space Station">International Space Station</a>. Two days later, it became the first commercial spacecraft to board the ISS.<sup class="reference" id="cite_ref-BBC_new_era_23-1"><a href="#cite_note-BBC_new_era-23">[17]</a></sup> <small>(<a href="#COTS_demo_missions">more details below</a>)</small> </td></tr> <tr> <th rowspan="3" scope="row" style="text-align:center;">4 </th> <td rowspan="2">8 October 2012,<br/>00:35<sup class="reference" id="cite_ref-SFN_LLog_27-0"><a href="#cite_note-SFN_LLog-27">[21]</a></sup> </td> <td rowspan="2"><a href="/wiki/Falcon_9_v1.0" title="Falcon 9 v1.0">F9 v1.0</a><sup class="reference" id="cite_ref-MuskMay2012_13-3"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B0006.1<sup class="reference" id="cite_ref-block_numbers_14-3"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td rowspan="2"><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/SpaceX_CRS-1" title="SpaceX CRS-1">SpaceX CRS-1</a><sup class="reference" id="cite_ref-sxManifest20120925_28-0"><a href="#cite_note-sxManifest20120925-28">[22]</a></sup><br/>(Dragon C103) </td> <td>4,700 kg (10,400 lb) </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> (<a href="/wiki/International_Space_Station" title="International Space Station">ISS</a>) </td> <td><a href="/wiki/NASA" title="NASA">NASA</a> (<a href="/wiki/Commercial_Resupply_Services" title="Commercial Resupply Services">CRS</a>) </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success </td> <td rowspan="2" style="background:#ececec; text-align:center;"><span class="nowrap">No attempt</span> </td></tr> <tr> <td><a href="/wiki/Orbcomm_(satellite)" title="Orbcomm (satellite)">Orbcomm-OG2</a><sup class="reference" id="cite_ref-Orbcomm_29-0"><a href="#cite_note-Orbcomm-29">[23]</a></sup> </td> <td>172 kg (379 lb)<sup class="reference" id="cite_ref-gunter-og2_30-0"><a href="#cite_note-gunter-og2-30">[24]</a></sup> </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> </td> <td><a href="/wiki/Orbcomm" title="Orbcomm">Orbcomm</a> </td> <td class="table-partial" style="background: wheat; color: black; vertical-align: middle; text-align: center;">Partial failure<sup class="reference" id="cite_ref-nyt-20121030_31-0"><a href="#cite_note-nyt-20121030-31">[25]</a></sup> </td></tr> <tr> <td colspan="9">CRS-1 was successful, but the <a href="/wiki/Secondary_payload" title="Secondary payload">secondary payload</a> was inserted into an abnormally low orbit and subsequently lost. This was due to one of the nine <a href="/wiki/SpaceX_Merlin" title="SpaceX Merlin">Merlin engines</a> shutting down during the launch, and NASA declining a second reignition, as per <a href="/wiki/International_Space_Station" title="International Space Station">ISS</a> visiting vehicle safety rules, the primary payload owner is contractually allowed to decline a second reignition. NASA stated that this was because SpaceX could not guarantee a high enough likelihood of the second stage completing the second burn successfully which was required to avoid any risk of secondary payload's collision with the ISS.<sup class="reference" id="cite_ref-OrbcommTotalLoss_32-0"><a href="#cite_note-OrbcommTotalLoss-32">[26]</a></sup><sup class="reference" id="cite_ref-sn20121011_33-0"><a href="#cite_note-sn20121011-33">[27]</a></sup><sup class="reference" id="cite_ref-34"><a href="#cite_note-34">[28]</a></sup> </td></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">5 </th> <td>1 March 2013,<br/>15:10 </td> <td><a href="/wiki/Falcon_9_v1.0" title="Falcon 9 v1.0">F9 v1.0</a><sup class="reference" id="cite_ref-MuskMay2012_13-4"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B0007.1<sup class="reference" id="cite_ref-block_numbers_14-4"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/SpaceX_CRS-2" title="SpaceX CRS-2">SpaceX CRS-2</a><sup class="reference" id="cite_ref-sxManifest20120925_28-1"><a href="#cite_note-sxManifest20120925-28">[22]</a></sup><br/>(Dragon C104) </td> <td>4,877 kg (10,752 lb) </td> <td><a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> (<a class="mw-redirect" href="/wiki/ISS" title="ISS">ISS</a>) </td> <td><a href="/wiki/NASA" title="NASA">NASA</a> (<a href="/wiki/Commercial_Resupply_Services" title="Commercial Resupply Services">CRS</a>) </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success </td> <td class="table-noAttempt" style="background: #ececec; color: black; vertical-align: middle; white-space: nowrap; text-align: center;">No attempt </td></tr> <tr> <td colspan="9">Last launch of the original Falcon 9 v1.0 <a href="/wiki/Launch_vehicle" title="Launch vehicle">launch vehicle</a>, first use of the unpressurized trunk section of Dragon.<sup class="reference" id="cite_ref-sxf9_20110321_35-0"><a href="#cite_note-sxf9_20110321-35">[29]</a></sup> </td></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">6 </th> <td>29 September 2013,<br/>16:00<sup class="reference" id="cite_ref-pa20130930_36-0"><a href="#cite_note-pa20130930-36">[30]</a></sup> </td> <td><a href="/wiki/Falcon_9_v1.1" title="Falcon 9 v1.1">F9 v1.1</a><sup class="reference" id="cite_ref-MuskMay2012_13-5"><a href="#cite_note-MuskMay2012-13">[7]</a></sup><br/>B1003<sup class="reference" id="cite_ref-block_numbers_14-5"><a href="#cite_note-block_numbers-14">[8]</a></sup> </td> <td><a class="mw-redirect" href="/wiki/Vandenberg_Air_Force_Base" title="Vandenberg Air Force Base">VAFB</a>,<br/><a href="/wiki/Vandenberg_Space_Launch_Complex_4" title="Vandenberg Space Launch Complex 4">SLC-4E</a> </td> <td><a href="/wiki/CASSIOPE" title="CASSIOPE">CASSIOPE</a><sup class="reference" id="cite_ref-sxManifest20120925_28-2"><a href="#cite_note-sxManifest20120925-28">[22]</a></sup><sup class="reference" id="cite_ref-CASSIOPE_MDA_37-0"><a href="#cite_note-CASSIOPE_MDA-37">[31]</a></sup> </td> <td>500 kg (1,100 lb) </td> <td><a href="/wiki/Polar_orbit" title="Polar orbit">Polar orbit</a> <a href="/wiki/Low_Earth_orbit" title="Low Earth orbit">LEO</a> </td> <td><a href="/wiki/Maxar_Technologies" title="Maxar Technologies">MDA</a> </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success<sup class="reference" id="cite_ref-pa20130930_36-1"><a href="#cite_note-pa20130930-36">[30]</a></sup> </td> <td class="table-no2" style="background: #ffdddd; color: black; vertical-align: middle; text-align: center;">Uncontrolled<br/><small>(ocean)</small><sup class="reference" id="cite_ref-ocean_landing_38-0"><a href="#cite_note-ocean_landing-38">[d]</a></sup> </td></tr> <tr> <td colspan="9">First commercial mission with a private customer, first launch from Vandenberg, and demonstration flight of Falcon 9 v1.1 with an improved 13-tonne to LEO capacity.<sup class="reference" id="cite_ref-sxf9_20110321_35-1"><a href="#cite_note-sxf9_20110321-35">[29]</a></sup> After separation from the second stage carrying Canadian commercial and scientific satellites, the first stage booster performed a controlled reentry,<sup class="reference" id="cite_ref-39"><a href="#cite_note-39">[32]</a></sup> and an <a href="/wiki/Falcon_9_first-stage_landing_tests" title="Falcon 9 first-stage landing tests">ocean touchdown test</a> for the first time. This provided good test data, even though the booster started rolling as it neared the ocean, leading to the shutdown of the central engine as the roll depleted it of fuel, resulting in a hard impact with the ocean.<sup class="reference" id="cite_ref-pa20130930_36-2"><a href="#cite_note-pa20130930-36">[30]</a></sup> This was the first known attempt of a rocket engine being lit to perform a supersonic retro propulsion, and allowed SpaceX to enter a public-private partnership with <a href="/wiki/NASA" title="NASA">NASA</a> and its Mars entry, descent, and landing technologies research projects.<sup class="reference" id="cite_ref-40"><a href="#cite_note-40">[33]</a></sup> <small>(<a href="#Maiden_flight_of_v1.1">more details below</a>)</small> </td></tr> <tr> <th rowspan="2" scope="row" style="text-align:center;">7 </th> <td>3 December 2013,<br/>22:41<sup class="reference" id="cite_ref-sfn_wwls20130624_41-0"><a href="#cite_note-sfn_wwls20130624-41">[34]</a></sup> </td> <td><a href="/wiki/Falcon_9_v1.1" title="Falcon 9 v1.1">F9 v1.1</a><br/>B1004 </td> <td><a href="/wiki/Cape_Canaveral_Space_Force_Station" title="Cape Canaveral Space Force Station">CCAFS</a>,<br/><a href="/wiki/Cape_Canaveral_Space_Launch_Complex_40" title="Cape Canaveral Space Launch Complex 40">SLC-40</a> </td> <td><a href="/wiki/SES-8" title="SES-8">SES-8</a><sup class="reference" id="cite_ref-sxManifest20120925_28-3"><a href="#cite_note-sxManifest20120925-28">[22]</a></sup><sup class="reference" id="cite_ref-spx-pr_42-0"><a href="#cite_note-spx-pr-42">[35]</a></sup><sup class="reference" id="cite_ref-aw20110323_43-0"><a href="#cite_note-aw20110323-43">[36]</a></sup> </td> <td>3,170 kg (6,990 lb) </td> <td><a href="/wiki/Geostationary_transfer_orbit" title="Geostationary transfer orbit">GTO</a> </td> <td><a href="/wiki/SES_S.A." title="SES S.A.">SES</a> </td> <td class="table-success" style="background: LightGreen; color: black; vertical-align: middle; text-align: center;">Success<sup class="reference" id="cite_ref-SNMissionStatus7_44-0"><a href="#cite_note-SNMissionStatus7-44">[37]</a></sup> </td> <td class="table-noAttempt" style="background: #ececec; color: black; vertical-align: middle; white-space: nowrap; text-align: center;">No attempt<br/><sup class="reference" id="cite_ref-sf10120131203_45-0"><a href="#cite_note-sf10120131203-45">[38]</a></sup> </td></tr> <tr> <td colspan="9">First <a href="/wiki/Geostationary_transfer_orbit" title="Geostationary transfer orbit">Geostationary transfer orbit</a> (GTO) launch for Falcon 9,<sup class="reference" id="cite_ref-spx-pr_42-1"><a href="#cite_note-spx-pr-42">[35]</a></sup> and first successful reignition of the second stage.<sup class="reference" id="cite_ref-46"><a href="#cite_note-46">[39]</a></sup> SES-8 was inserted into a <a href="/wiki/Geostationary_transfer_orbit" title="Geostationary transfer orbit">Super-Synchronous Transfer Orbit</a> of 79,341 km (49,300 mi) in apogee with an <a href="/wiki/Orbital_inclination" title="Orbital inclination">inclination</a> of 20.55° to the <a href="/wiki/Equator" title="Equator">equator</a>. </td></tr></tbody></table>

You should able to see the columns names embedded in the table header elements <th> as follows:

<tr> <th scope="col">Flight No. </th> <th scope="col">Date and<br/>time (<a href="/wiki/Coordinated_Universal_Time" title="Coordinated Universal Time">UTC</a>) </th> <th scope="col"><a href="/wiki/List_of_Falcon_9_first-stage_boosters" title="List of Falcon 9 first-stage boosters">Version,<br/>Booster</a> <sup class="reference" id="cite_ref-booster_11-0"><a href="#cite_note-booster-11">[b]</a></sup> </th> <th scope="col">Launch site </th> <th scope="col">Payload<sup class="reference" id="cite_ref-Dragon_12-0"><a href="#cite_note-Dragon-12">[c]</a></sup> </th> <th scope="col">Payload mass </th> <th scope="col">Orbit </th> <th scope="col">Customer </th> <th scope="col">Launch<br/>outcome </th> <th scope="col"><a href="/wiki/Falcon_9_first-stage_landing_tests" title="Falcon 9 first-stage landing tests">Booster<br/>landing</a> </th></tr>

Next, we just need to iterate through the <th> elements and apply the provided extract_column_from_header() to extract column name one by one

column_names = [] # Apply find_all() function with `th` element on first_launch_table # Iterate each th element and apply the provided extract_column_from_header() to get a column name # Append the Non-empty column name (`if name is not None and len(name) > 0`) into a list called column_names for row in first_launch_table.find_all('th'): name = extract_column_from_header(row) if(name != None and len(name) > 0): column_names.append(name)

Check the extracted column names

print(column_names)
['Flight No.', 'Date and time ( )', 'Launch site', 'Payload', 'Payload mass', 'Orbit', 'Customer', 'Launch outcome']

TASK 3: Create a data frame by parsing the launch HTML tables

We will create an empty dictionary with keys from the extracted column names in the previous task. Later, this dictionary will be converted into a Pandas dataframe

launch_dict= dict.fromkeys(column_names) # Remove an irrelevant column del launch_dict['Date and time ( )'] # Let's initial the launch_dict with each value to be an empty list launch_dict['Flight No.'] = [] launch_dict['Launch site'] = [] launch_dict['Payload'] = [] launch_dict['Payload mass'] = [] launch_dict['Orbit'] = [] launch_dict['Customer'] = [] launch_dict['Launch outcome'] = [] # Added some new columns launch_dict['Version Booster']=[] launch_dict['Booster landing']=[] launch_dict['Date']=[] launch_dict['Time']=[]

Next, we just need to fill up the launch_dict with launch records extracted from table rows.

Usually, HTML tables in Wiki pages are likely to contain unexpected annotations and other types of noises, such as reference links B0004.1[8], missing values N/A [e], inconsistent formatting, etc.

To simplify the parsing process, we have provided an incomplete code snippet below to help you to fill up the launch_dict. Please complete the following code snippet with TODOs or you can choose to write your own logic to parse all launch tables:

extracted_row = 0 #Extract each table for table_number,table in enumerate(soup.find_all('table',"wikitable plainrowheaders collapsible")): # get table row for rows in table.find_all("tr"): #check to see if first table heading is as number corresponding to launch a number if rows.th: if rows.th.string: flight_number=rows.th.string.strip() flag=flight_number.isdigit() else: flag=False #get table element row=rows.find_all('td') #if it is number save cells in a dictonary if flag: extracted_row += 1 # Flight Number value # Append the flight_number into launch_dict with key `Flight No.` launch_dict["Flight No."].append(flight_number) # Date value #Append the date into launch_dict with key `Date` datatimelist=date_time(row[0]) date = datatimelist[0].strip(',') launch_dict["Date"].append(date) # Time value #Append the time into launch_dict with key `Time` time = datatimelist[1] launch_dict["Time"].append(time) # Booster version #Append the bv into launch_dict with key `Version Booster` bv=booster_version(row[1]) if not(bv): bv=row[1].a.string launch_dict["Version Booster"].append(bv) # Launch Site #Append the bv into launch_dict with key `Launch site` launch_site = row[2].a.string launch_dict['Launch site'].append(launch_site) # Payload #Append the payload into launch_dict with key `Payload` payload = row[3].a.string launch_dict['Payload'].append(payload) # Payload Mass #Append the payload_mass into launch_dict with key `Payload mass` payload_mass = get_mass(row[4]) launch_dict['Payload mass'].append(payload_mass) # Orbit #Append the orbit into launch_dict with key `Orbit` orbit = row[5].a.string launch_dict['Orbit'].append(orbit) # Customer #Append the customer into launch_dict with key `Customer` if row[6].a != None: customer = row[6].a.string else: customer = 'None' launch_dict['Customer'].append(customer) # Launch outcome #Append the launch_outcome into launch_dict with key `Launch outcome` launch_outcome = list(row[7].strings)[0] launch_dict['Launch outcome'].append(launch_outcome) # Booster landing #Append the booster landing into launch_dict with key `Booster landing` booster_landing = landing_status(row[8]) launch_dict['Booster landing'].append(booster_landing) print(f"Flight Number: {flight_number}, Date: {date}, Time: {time} \n \ Booster Version {bv}, Launch Site: {launch_site} \n \ Payload: {payload}, Orbit: {orbit} \n \ Customer: {customer}, Launch Outcome: {launch_outcome}\ Booster Landing: {booster_landing} \n \ *** ")
Flight Number: 1, Date: 4 June 2010, Time: 18:45 Booster Version F9 v1.0B0003.1, Launch Site: CCAFS Payload: Dragon Spacecraft Qualification Unit, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 2, Date: 8 December 2010, Time: 15:43 Booster Version F9 v1.0B0004.1, Launch Site: CCAFS Payload: Dragon, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 3, Date: 22 May 2012, Time: 07:44 Booster Version F9 v1.0B0005.1, Launch Site: CCAFS Payload: Dragon, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 4, Date: 8 October 2012, Time: 00:35 Booster Version F9 v1.0B0006.1, Launch Site: CCAFS Payload: SpaceX CRS-1, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 5, Date: 1 March 2013, Time: 15:10 Booster Version F9 v1.0B0007.1, Launch Site: CCAFS Payload: SpaceX CRS-2, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 6, Date: 29 September 2013, Time: 16:00 Booster Version F9 v1.1B1003, Launch Site: VAFB Payload: CASSIOPE, Orbit: Polar orbit Customer: MDA, Launch Outcome: Success Booster Landing: Uncontrolled *** Flight Number: 7, Date: 3 December 2013, Time: 22:41 Booster Version F9 v1.1, Launch Site: CCAFS Payload: SES-8, Orbit: GTO Customer: SES, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 8, Date: 6 January 2014, Time: 22:06 Booster Version F9 v1.1, Launch Site: CCAFS Payload: Thaicom 6, Orbit: GTO Customer: Thaicom, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 9, Date: 18 April 2014, Time: 19:25 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: SpaceX CRS-3, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Controlled *** Flight Number: 10, Date: 14 July 2014, Time: 15:15 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: Orbcomm-OG2, Orbit: LEO Customer: Orbcomm, Launch Outcome: Success Booster Landing: Controlled *** Flight Number: 11, Date: 5 August 2014, Time: 08:00 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: AsiaSat 8, Orbit: GTO Customer: AsiaSat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 12, Date: 7 September 2014, Time: 05:00 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: AsiaSat 6, Orbit: GTO Customer: AsiaSat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 13, Date: 21 September 2014, Time: 05:52 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: SpaceX CRS-4, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Uncontrolled *** Flight Number: 14, Date: 10 January 2015, Time: 09:47 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: SpaceX CRS-5, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 15, Date: 11 February 2015, Time: 23:03 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: DSCOVR, Orbit: HEO Customer: USAF, Launch Outcome: Success Booster Landing: Controlled *** Flight Number: 16, Date: 2 March 2015, Time: 03:50 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: ABS-3A, Orbit: GTO Customer: ABS, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 17, Date: 14 April 2015, Time: 20:10 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: SpaceX CRS-6, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 18, Date: 27 April 2015, Time: 23:03 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: TürkmenÄlem 52°E / MonacoSAT, Orbit: GTO Customer: None, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 19, Date: 28 June 2015, Time: 14:21 Booster Version F9 v1.1, Launch Site: Cape Canaveral Payload: SpaceX CRS-7, Orbit: LEO Customer: NASA, Launch Outcome: Failure Booster Landing: Precluded *** Flight Number: 20, Date: 22 December 2015, Time: 01:29 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: Orbcomm-OG2, Orbit: LEO Customer: Orbcomm, Launch Outcome: Success Booster Landing: Success *** Flight Number: 21, Date: 17 January 2016, Time: 18:42 Booster Version F9 v1.1, Launch Site: VAFB Payload: Jason-3, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 22, Date: 4 March 2016, Time: 23:35 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: SES-9, Orbit: GTO Customer: SES, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 23, Date: 8 April 2016, Time: 20:43 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: SpaceX CRS-8, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 24, Date: 6 May 2016, Time: 05:21 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: JCSAT-14, Orbit: GTO Customer: SKY Perfect JSAT Group, Launch Outcome: Success Booster Landing: Success *** Flight Number: 25, Date: 27 May 2016, Time: 21:39 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: Thaicom 8, Orbit: GTO Customer: Thaicom, Launch Outcome: Success Booster Landing: Success *** Flight Number: 26, Date: 15 June 2016, Time: 14:29 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: ABS-2A, Orbit: GTO Customer: ABS, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 27, Date: 18 July 2016, Time: 04:45 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: SpaceX CRS-9, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 28, Date: 14 August 2016, Time: 05:26 Booster Version F9 FT, Launch Site: Cape Canaveral Payload: JCSAT-16, Orbit: GTO Customer: SKY Perfect JSAT Group, Launch Outcome: Success Booster Landing: Success *** Flight Number: 29, Date: 14 January 2017, Time: 17:54 Booster Version F9 FT, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Success *** Flight Number: 30, Date: 19 February 2017, Time: 14:39 Booster Version F9 FT, Launch Site: KSC Payload: SpaceX CRS-10, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 31, Date: 16 March 2017, Time: 06:00 Booster Version F9 FT, Launch Site: KSC Payload: EchoStar 23, Orbit: GTO Customer: EchoStar, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 32, Date: 30 March 2017, Time: 22:27 Booster Version F9 FT♺, Launch Site: KSC Payload: SES-10, Orbit: GTO Customer: SES, Launch Outcome: Success Booster Landing: Success *** Flight Number: 33, Date: 1 May 2017, Time: 11:15 Booster Version F9 FT, Launch Site: KSC Payload: NROL-76, Orbit: LEO Customer: NRO, Launch Outcome: Success Booster Landing: Success *** Flight Number: 34, Date: 15 May 2017, Time: 23:21 Booster Version F9 FT, Launch Site: KSC Payload: Inmarsat-5 F4, Orbit: GTO Customer: Inmarsat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 35, Date: 3 June 2017, Time: 21:07 Booster Version F9 FT, Launch Site: KSC Payload: SpaceX CRS-11, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 36, Date: 23 June 2017, Time: 19:10 Booster Version F9 FTB1029.2, Launch Site: KSC Payload: BulgariaSat-1, Orbit: GTO Customer: Bulsatcom, Launch Outcome: Success Booster Landing: Success *** Flight Number: 37, Date: 25 June 2017, Time: 20:25 Booster Version F9 FT, Launch Site: VAFB Payload: Iridium NEXT, Orbit: LEO Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Success *** Flight Number: 38, Date: 5 July 2017, Time: 23:38 Booster Version F9 FT, Launch Site: KSC Payload: Intelsat 35e, Orbit: GTO Customer: Intelsat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 39, Date: 14 August 2017, Time: 16:31 Booster Version F9 B4, Launch Site: KSC Payload: SpaceX CRS-12, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 40, Date: 24 August 2017, Time: 18:51 Booster Version F9 FT, Launch Site: VAFB Payload: Formosat-5, Orbit: SSO Customer: NSPO, Launch Outcome: Success Booster Landing: Success *** Flight Number: 41, Date: 7 September 2017, Time: 14:00 Booster Version F9 B4, Launch Site: KSC Payload: Boeing X-37B, Orbit: LEO Customer: USAF, Launch Outcome: Success Booster Landing: Success *** Flight Number: 42, Date: 9 October 2017, Time: 12:37 Booster Version F9 B4, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Success *** Flight Number: 43, Date: 11 October 2017, Time: 22:53:00 Booster Version F9 FTB1031.2, Launch Site: KSC Payload: SES-11, Orbit: GTO Customer: SES S.A., Launch Outcome: Success Booster Landing: Success *** Flight Number: 44, Date: 30 October 2017, Time: 19:34 Booster Version F9 B4, Launch Site: KSC Payload: Koreasat 5A, Orbit: GTO Customer: KT Corporation, Launch Outcome: Success Booster Landing: Success *** Flight Number: 45, Date: 15 December 2017, Time: 15:36 Booster Version F9 FTB1035.2, Launch Site: Cape Canaveral Payload: SpaceX CRS-13, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 46, Date: 23 December 2017, Time: 01:27 Booster Version F9 FTB1036.2, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Controlled *** Flight Number: 47, Date: 8 January 2018, Time: 01:00 Booster Version F9 B4, Launch Site: CCAFS Payload: Zuma, Orbit: LEO Customer: Northrop Grumman, Launch Outcome: Success Booster Landing: Success *** Flight Number: 48, Date: 31 January 2018, Time: 21:25 Booster Version F9 FTB1032.2, Launch Site: CCAFS Payload: GovSat-1, Orbit: GTO Customer: SES, Launch Outcome: Success Booster Landing: Controlled *** Flight Number: 49, Date: 22 February 2018, Time: 14:17 Booster Version F9 FTB1038.2, Launch Site: VAFB Payload: Paz, Orbit: SSO Customer: Hisdesat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 50, Date: 6 March 2018, Time: 05:33 Booster Version F9 B4, Launch Site: CCAFS Payload: Hispasat 30W-6, Orbit: GTO Customer: Hispasat, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 51, Date: 30 March 2018, Time: 14:14 Booster Version F9 B4B1041.2, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 52, Date: 2 April 2018, Time: 20:30 Booster Version F9 B4B1039.2, Launch Site: CCAFS Payload: SpaceX CRS-14, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 53, Date: 18 April 2018, Time: 22:51 Booster Version F9 B4, Launch Site: CCAFS Payload: Transiting Exoplanet Survey Satellite, Orbit: HEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 54, Date: 11 May 2018, Time: 20:14 Booster Version F9 B5B1046.1, Launch Site: KSC Payload: Bangabandhu-1, Orbit: GTO Customer: Thales-Alenia, Launch Outcome: Success Booster Landing: Success *** Flight Number: 55, Date: 22 May 2018, Time: 19:47 Booster Version F9 B4B1043.2, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 56, Date: 4 June 2018, Time: 04:45 Booster Version F9 B4B1040.2, Launch Site: CCAFS Payload: SES-12, Orbit: GTO Customer: SES, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 57, Date: 29 June 2018, Time: 09:42 Booster Version F9 B4B1045.2, Launch Site: CCAFS Payload: SpaceX CRS-15, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 58, Date: 22 July 2018, Time: 05:50 Booster Version F9 B5, Launch Site: CCAFS Payload: Telstar 19V, Orbit: GTO Customer: Telesat, Launch Outcome: Success Booster Landing: Success *** Flight Number: 59, Date: 25 July 2018, Time: 11:39 Booster Version F9 B5B1048, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Success *** Flight Number: 60, Date: 7 August 2018, Time: 05:18 Booster Version F9 B5B1046.2, Launch Site: CCAFS Payload: Merah Putih, Orbit: GTO Customer: Telkom Indonesia, Launch Outcome: Success Booster Landing: Success *** Flight Number: 61, Date: 10 September 2018, Time: 04:45 Booster Version F9 B5, Launch Site: CCAFS Payload: Telstar 18V, Orbit: GTO Customer: Telesat, Launch Outcome: Success Booster Landing: Success *** Flight Number: 62, Date: 8 October 2018, Time: 02:22 Booster Version F9 B5B1048.2, Launch Site: VAFB Payload: SAOCOM 1A, Orbit: SSO Customer: CONAE, Launch Outcome: Success Booster Landing: Success *** Flight Number: 63, Date: 15 November 2018, Time: 20:46 Booster Version F9 B5B1047.2, Launch Site: KSC Payload: Es'hail 2, Orbit: GTO Customer: Es'hailSat, Launch Outcome: Success Booster Landing: Success *** Flight Number: 64, Date: 3 December 2018, Time: 18:34:05 Booster Version F9 B5B1046.3, Launch Site: VAFB Payload: SSO-A, Orbit: SSO Customer: Spaceflight Industries, Launch Outcome: Success Booster Landing: Success *** Flight Number: 65, Date: 5 December 2018, Time: 18:16 Booster Version F9 B5, Launch Site: CCAFS Payload: SpaceX CRS-16, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 66, Date: 23 December 2018, Time: 13:51 Booster Version F9 B5, Launch Site: CCAFS Payload: GPS III, Orbit: MEO Customer: USAF, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 67, Date: 11 January 2019, Time: 15:31 Booster Version F9 B5B1049.2, Launch Site: VAFB Payload: Iridium NEXT, Orbit: Polar Customer: Iridium Communications, Launch Outcome: Success Booster Landing: Success *** Flight Number: 68, Date: 22 February 2019, Time: 01:45 Booster Version F9 B5B1048.3, Launch Site: CCAFS Payload: Nusantara Satu, Orbit: GTO Customer: PSN, Launch Outcome: Success Booster Landing: Success *** Flight Number: 69, Date: 2 March 2019, Time: 07:49 Booster Version F9 B5[268], Launch Site: KSC Payload: Crew Dragon Demo-1, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 70, Date: 4 May 2019, Time: 06:48 Booster Version F9 B5, Launch Site: CCAFS Payload: SpaceX CRS-17, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 71, Date: 24 May 2019, Time: 02:30 Booster Version F9 B5B1049.3, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 72, Date: 12 June 2019, Time: 14:17 Booster Version F9 B5B1051.2, Launch Site: VAFB Payload: RADARSAT Constellation, Orbit: SSO Customer: Canadian Space Agency, Launch Outcome: Success Booster Landing: Success *** Flight Number: 73, Date: 25 July 2019, Time: 22:01 Booster Version F9 B5B1056.2, Launch Site: CCAFS Payload: SpaceX CRS-18, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 74, Date: 6 August 2019, Time: 23:23 Booster Version F9 B5B1047.3, Launch Site: CCAFS Payload: AMOS-17, Orbit: GTO Customer: Spacecom, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 75, Date: 11 November 2019, Time: 14:56 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 76, Date: 5 December 2019, Time: 17:29 Booster Version F9 B5, Launch Site: CCAFS Payload: SpaceX CRS-19, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 77, Date: 17 December 2019, Time: 00:10 Booster Version F9 B5B1056.3, Launch Site: CCAFS Payload: JCSat-18, Orbit: GTO Customer: Sky Perfect JSAT, Launch Outcome: Success Booster Landing: Success *** Flight Number: 78, Date: 7 January 2020, Time: 02:19:21 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 79, Date: 19 January 2020, Time: 15:30 Booster Version F9 B5, Launch Site: KSC Payload: Crew Dragon in-flight abort test, Orbit: Sub-orbital Customer: NASA, Launch Outcome: Success Booster Landing: No attempt *** Flight Number: 80, Date: 29 January 2020, Time: 14:07 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 81, Date: 17 February 2020, Time: 15:05 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 82, Date: 7 March 2020, Time: 04:50 Booster Version F9 B5, Launch Site: CCAFS Payload: SpaceX CRS-20, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 83, Date: 18 March 2020, Time: 12:16 Booster Version F9 B5, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 84, Date: 22 April 2020, Time: 19:30 Booster Version F9 B5, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 85, Date: 30 May 2020, Time: 19:22 Booster Version F9 B5, Launch Site: KSC Payload: Crew Dragon Demo-2, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 86, Date: 4 June 2020, Time: 01:25 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 87, Date: 13 June 2020, Time: 09:21 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 88, Date: 30 June 2020, Time: 20:10:46 Booster Version F9 B5, Launch Site: CCAFS Payload: GPS III, Orbit: MEO Customer: U.S. Space Force, Launch Outcome: Success Booster Landing: Success *** Flight Number: 89, Date: 20 July 2020, Time: 21:30 Booster Version F9 B5B1058.2, Launch Site: CCAFS Payload: ANASIS-II, Orbit: GTO Customer: Republic of Korea Army, Launch Outcome: Success Booster Landing: Success *** Flight Number: 90, Date: 7 August 2020, Time: 05:12 Booster Version F9 B5, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 91, Date: 18 August 2020, Time: 14:31 Booster Version F9 B5B1049.6, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 92, Date: 30 August 2020, Time: 23:18 Booster Version F9 B5, Launch Site: CCAFS Payload: SAOCOM 1B, Orbit: SSO Customer: CONAE, Launch Outcome: Success Booster Landing: Success *** Flight Number: 93, Date: 3 September 2020, Time: 12:46:14 Booster Version F9 B5B1060.2, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 94, Date: 6 October 2020, Time: 11:29:34 Booster Version F9 B5B1058.3, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 95, Date: 18 October 2020, Time: 12:25:57 Booster Version F9 B5B1051.6, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 96, Date: 24 October 2020, Time: 15:31:34 Booster Version F9 B5, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 97, Date: 5 November 2020, Time: 23:24:23 Booster Version F9 B5, Launch Site: CCAFS Payload: GPS III, Orbit: MEO Customer: USSF, Launch Outcome: Success Booster Landing: Success *** Flight Number: 98, Date: 16 November 2020, Time: 00:27 Booster Version F9 B5, Launch Site: KSC Payload: Crew-1, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 99, Date: 21 November 2020, Time: 17:17:08 Booster Version F9 B5, Launch Site: VAFB Payload: Sentinel-6 Michael Freilich (Jason-CS A), Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 100, Date: 25 November 2020, Time: 02:13 Booster Version F9 B5 ♺, Launch Site: CCAFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 101, Date: 6 December 2020, Time: 16:17:08 Booster Version F9 B5 ♺, Launch Site: KSC Payload: SpaceX CRS-21, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 102, Date: 13 December 2020, Time: 17:30:00 Booster Version F9 B5 ♺, Launch Site: CCSFS Payload: SXM-7, Orbit: GTO Customer: Sirius XM, Launch Outcome: Success Booster Landing: Success *** Flight Number: 103, Date: 19 December 2020, Time: 14:00:00 Booster Version F9 B5 ♺, Launch Site: KSC Payload: NROL-108, Orbit: LEO Customer: NRO, Launch Outcome: Success Booster Landing: Success *** Flight Number: 104, Date: 8 January 2021, Time: 02:15 Booster Version F9 B5, Launch Site: CCSFS Payload: Türksat 5A, Orbit: GTO Customer: Türksat, Launch Outcome: Success Booster Landing: Success *** Flight Number: 105, Date: 20 January 2021, Time: 13:02 Booster Version F9 B5B1051.8, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 106, Date: 24 January 2021, Time: 15:00 Booster Version F9 B5B1058.5, Launch Site: CCSFS Payload: Transporter-1, Orbit: SSO Customer: None, Launch Outcome: Success Booster Landing: Success *** Flight Number: 107, Date: 4 February 2021, Time: 06:19 Booster Version F9 B5 ♺, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 108, Date: 16 February 2021, Time: 03:59:37 Booster Version F9 B5 ♺, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Failure *** Flight Number: 109, Date: 4 March 2021, Time: 08:24 Booster Version F9 B5 ♺, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 110, Date: 11 March 2021, Time: 08:13:29 Booster Version F9 B5 ♺, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 111, Date: 14 March 2021, Time: 10:01 Booster Version F9 B5 ♺, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 112, Date: 24 March 2021, Time: 08:28 Booster Version F9 B5B1060.6, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 113, Date: 7 April 2021, Time: 16:34 Booster Version F9 B5 ♺, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 114, Date: 23 April 2021, Time: 9:49 Booster Version F9 B5B1061.2, Launch Site: KSC Payload: Crew-2, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 115, Date: 29 April 2021, Time: 03:44 Booster Version F9 B5B1060.7, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 116, Date: 4 May 2021, Time: 19:01 Booster Version F9 B5B1049.9, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 117, Date: 9 May 2021, Time: 06:42 Booster Version F9 B5B1051.10, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 118, Date: 15 May 2021, Time: 22:56 Booster Version F9 B5B1058.8, Launch Site: KSC Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 119, Date: 26 May 2021, Time: 18:59 Booster Version F9 B5B1063.2, Launch Site: CCSFS Payload: Starlink, Orbit: LEO Customer: SpaceX, Launch Outcome: Success Booster Landing: Success *** Flight Number: 120, Date: 3 June 2021, Time: 17:29 Booster Version F9 B5B1067.1, Launch Site: KSC Payload: SpaceX CRS-22, Orbit: LEO Customer: NASA, Launch Outcome: Success Booster Landing: Success *** Flight Number: 121, Date: 6 June 2021, Time: 04:26 Booster Version F9 B5, Launch Site: CCSFS Payload: SXM-8, Orbit: GTO Customer: Sirius XM, Launch Outcome: Success Booster Landing: Success ***

After you have fill in the parsed launch record values into launch_dict, you can create a dataframe from it.

df = pd.DataFrame(launch_dict)

We can now export it to a CSV for the next section, but to make the answers consistent and in case you have difficulties finishing this lab.

Following labs will be using a provided dataset to make each lab independent.

df.to_csv('spacex_web_scraped.csv', index=False)

Authors

Change Log

Date (YYYY-MM-DD)VersionChanged ByChange Description
2021-06-091.0Yan LuoTasks updates
2020-11-101.0NayefCreated the initial version

Copyright © 2021 IBM Corporation. All rights reserved.