Skip to content

Instantly share code, notes, and snippets.

@rejsmont
Last active November 18, 2020 11:36
Show Gist options
  • Save rejsmont/b7964781e0331a45ec9a7054e17a7496 to your computer and use it in GitHub Desktop.
Save rejsmont/b7964781e0331a45ec9a7054e17a7496 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# What is the minimum time gap between two _Ariane 5_ missions?\n",
"\n",
"This was [a question](https://twitter.com/ArianeGroup/status/1328797599613259780) asked by [@ArianeGroup](https://twitter.com/ArianeGroup/) on Twitter. Let's dig into it!\n",
"\n",
"![What is the minimum time gap between two _Ariane 5_ missions?](https://pbs.twimg.com/media/EnDWX9IXcAE6elT?format=jpg&name=small)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load the data\n",
"\n",
"`Pandas` is awesome because you can load all tables from a website as dataframes. And Wikipedia has [all the data](https://en.wikipedia.org/wiki/Ariane_5) we need!"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>#</th>\n",
" <th>Flight No.</th>\n",
" <th>DateTime (UTC)</th>\n",
" <th>Rocket typeSerial No.</th>\n",
" <th>Payload</th>\n",
" <th>Payload mass</th>\n",
" <th>Orbit</th>\n",
" <th>Customers</th>\n",
" <th>Launchoutcome</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>V-88[62]</td>\n",
" <td>4 June 199612:34</td>\n",
" <td>G501</td>\n",
" <td>Cluster</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Failure</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>V-88[62]</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>V-101</td>\n",
" <td>30 October 199713:43</td>\n",
" <td>G502</td>\n",
" <td>MaqSat-H, TEAMSAT, MaqSat-B, YES</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Partial failure[63]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2</td>\n",
" <td>V-101</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>3</td>\n",
" <td>V-112</td>\n",
" <td>21 October 199816:37</td>\n",
" <td>G503</td>\n",
" <td>MaqSat 3, ARD</td>\n",
" <td>~6,800 kg</td>\n",
" <td>GTO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>204</th>\n",
" <td>105</td>\n",
" <td>VA-249</td>\n",
" <td>6 August 201919:30</td>\n",
" <td>ECA5108</td>\n",
" <td>EDRS-C / HYLAS-3[90][91] Intelsat 39[92]</td>\n",
" <td>10,594 kg</td>\n",
" <td>GTO</td>\n",
" <td>ESA Avanti Communications Intelsat</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>205</th>\n",
" <td>106</td>\n",
" <td>VA-250</td>\n",
" <td>26 November 201921:23[93]</td>\n",
" <td>ECA5109</td>\n",
" <td>Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96]</td>\n",
" <td>10,495 kg</td>\n",
" <td>GTO</td>\n",
" <td>InmarsatGovernment of Egypt</td>\n",
" <td>Success[97]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>206</th>\n",
" <td>107</td>\n",
" <td>VA-251</td>\n",
" <td>16 January 202021:05</td>\n",
" <td>ECA5110</td>\n",
" <td>Eutelsat Konnect (African Broadband Satellite)...</td>\n",
" <td>7,888 kg</td>\n",
" <td>GTO</td>\n",
" <td>EutelsatISRO</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>207</th>\n",
" <td>108</td>\n",
" <td>VA-252</td>\n",
" <td>18 February 202022:18</td>\n",
" <td>ECA5111</td>\n",
" <td>JCSAT-17GEO-KOMPSAT 2B</td>\n",
" <td>9,236 kg</td>\n",
" <td>GTO</td>\n",
" <td>SKY Perfect JSATKARI</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>208</th>\n",
" <td>109</td>\n",
" <td>VA-253</td>\n",
" <td>15 August 202022:04</td>\n",
" <td>ECA5112</td>\n",
" <td>Galaxy 30MEV-2BSAT-4b</td>\n",
" <td>10,468 kg[99]inc 765 kg of support structures.</td>\n",
" <td>GTO</td>\n",
" <td>IntelsatNorthrop GrummanB-SAT</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>209 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" # Flight No. DateTime (UTC) Rocket typeSerial No. \\\n",
"0 1 V-88[62] 4 June 199612:34 G501 \n",
"1 1 V-88[62] NaN NaN \n",
"2 2 V-101 30 October 199713:43 G502 \n",
"3 2 V-101 NaN NaN \n",
"4 3 V-112 21 October 199816:37 G503 \n",
".. ... ... ... ... \n",
"204 105 VA-249 6 August 201919:30 ECA5108 \n",
"205 106 VA-250 26 November 201921:23[93] ECA5109 \n",
"206 107 VA-251 16 January 202021:05 ECA5110 \n",
"207 108 VA-252 18 February 202022:18 ECA5111 \n",
"208 109 VA-253 15 August 202022:04 ECA5112 \n",
"\n",
" Payload \\\n",
"0 Cluster \n",
"1 NaN \n",
"2 MaqSat-H, TEAMSAT, MaqSat-B, YES \n",
"3 NaN \n",
"4 MaqSat 3, ARD \n",
".. ... \n",
"204 EDRS-C / HYLAS-3[90][91] Intelsat 39[92] \n",
"205 Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96] \n",
"206 Eutelsat Konnect (African Broadband Satellite)... \n",
"207 JCSAT-17GEO-KOMPSAT 2B \n",
"208 Galaxy 30MEV-2BSAT-4b \n",
"\n",
" Payload mass Orbit \\\n",
"0 NaN NaN \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 NaN NaN \n",
"4 ~6,800 kg GTO \n",
".. ... ... \n",
"204 10,594 kg GTO \n",
"205 10,495 kg GTO \n",
"206 7,888 kg GTO \n",
"207 9,236 kg GTO \n",
"208 10,468 kg[99]inc 765 kg of support structures. GTO \n",
"\n",
" Customers Launchoutcome \n",
"0 NaN Failure \n",
"1 NaN NaN \n",
"2 NaN Partial failure[63] \n",
"3 NaN NaN \n",
"4 NaN Success \n",
".. ... ... \n",
"204 ESA Avanti Communications Intelsat Success \n",
"205 InmarsatGovernment of Egypt Success[97] \n",
"206 EutelsatISRO Success \n",
"207 SKY Perfect JSATKARI Success \n",
"208 IntelsatNorthrop GrummanB-SAT Success \n",
"\n",
"[209 rows x 9 columns]"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"\n",
"dfs = pd.read_html('https://en.wikipedia.org/wiki/Ariane_5')\n",
"df = dfs[2]\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Data cleanup\n",
"\n",
"Dates are in funny format and include bookmarks - lets clean this up with some regex magic and type conversions. And lets sanitize the dataframe index too."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Flight No.</th>\n",
" <th>DateTime (UTC)</th>\n",
" <th>Rocket typeSerial No.</th>\n",
" <th>Payload</th>\n",
" <th>Payload mass</th>\n",
" <th>Orbit</th>\n",
" <th>Customers</th>\n",
" <th>Launchoutcome</th>\n",
" </tr>\n",
" <tr>\n",
" <th>#</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>V-88[62]</td>\n",
" <td>1996-06-04 12:34:00</td>\n",
" <td>G501</td>\n",
" <td>Cluster</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Failure</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>V-101</td>\n",
" <td>1997-10-30 13:43:00</td>\n",
" <td>G502</td>\n",
" <td>MaqSat-H, TEAMSAT, MaqSat-B, YES</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Partial failure[63]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>V-112</td>\n",
" <td>1998-10-21 16:37:00</td>\n",
" <td>G503</td>\n",
" <td>MaqSat 3, ARD</td>\n",
" <td>~6,800 kg</td>\n",
" <td>GTO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>V-119</td>\n",
" <td>1999-12-10 14:32:00</td>\n",
" <td>G504</td>\n",
" <td>XMM-Newton</td>\n",
" <td>3,800 kg</td>\n",
" <td>HEO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>V-128</td>\n",
" <td>2000-03-21 23:28:00</td>\n",
" <td>G505</td>\n",
" <td>INSAT-3BAsiaStar</td>\n",
" <td>~5,800 kg</td>\n",
" <td>GTO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>105</th>\n",
" <td>VA-249</td>\n",
" <td>2019-08-06 19:30:00</td>\n",
" <td>ECA5108</td>\n",
" <td>EDRS-C / HYLAS-3[90][91] Intelsat 39[92]</td>\n",
" <td>10,594 kg</td>\n",
" <td>GTO</td>\n",
" <td>ESA Avanti Communications Intelsat</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>106</th>\n",
" <td>VA-250</td>\n",
" <td>2019-11-26 21:23:00</td>\n",
" <td>ECA5109</td>\n",
" <td>Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96]</td>\n",
" <td>10,495 kg</td>\n",
" <td>GTO</td>\n",
" <td>InmarsatGovernment of Egypt</td>\n",
" <td>Success[97]</td>\n",
" </tr>\n",
" <tr>\n",
" <th>107</th>\n",
" <td>VA-251</td>\n",
" <td>2020-01-16 21:05:00</td>\n",
" <td>ECA5110</td>\n",
" <td>Eutelsat Konnect (African Broadband Satellite)...</td>\n",
" <td>7,888 kg</td>\n",
" <td>GTO</td>\n",
" <td>EutelsatISRO</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>108</th>\n",
" <td>VA-252</td>\n",
" <td>2020-02-18 22:18:00</td>\n",
" <td>ECA5111</td>\n",
" <td>JCSAT-17GEO-KOMPSAT 2B</td>\n",
" <td>9,236 kg</td>\n",
" <td>GTO</td>\n",
" <td>SKY Perfect JSATKARI</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>VA-253</td>\n",
" <td>2020-08-15 22:04:00</td>\n",
" <td>ECA5112</td>\n",
" <td>Galaxy 30MEV-2BSAT-4b</td>\n",
" <td>10,468 kg[99]inc 765 kg of support structures.</td>\n",
" <td>GTO</td>\n",
" <td>IntelsatNorthrop GrummanB-SAT</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>109 rows × 8 columns</p>\n",
"</div>"
],
"text/plain": [
" Flight No. DateTime (UTC) Rocket typeSerial No. \\\n",
"# \n",
"1 V-88[62] 1996-06-04 12:34:00 G501 \n",
"2 V-101 1997-10-30 13:43:00 G502 \n",
"3 V-112 1998-10-21 16:37:00 G503 \n",
"4 V-119 1999-12-10 14:32:00 G504 \n",
"5 V-128 2000-03-21 23:28:00 G505 \n",
".. ... ... ... \n",
"105 VA-249 2019-08-06 19:30:00 ECA5108 \n",
"106 VA-250 2019-11-26 21:23:00 ECA5109 \n",
"107 VA-251 2020-01-16 21:05:00 ECA5110 \n",
"108 VA-252 2020-02-18 22:18:00 ECA5111 \n",
"109 VA-253 2020-08-15 22:04:00 ECA5112 \n",
"\n",
" Payload \\\n",
"# \n",
"1 Cluster \n",
"2 MaqSat-H, TEAMSAT, MaqSat-B, YES \n",
"3 MaqSat 3, ARD \n",
"4 XMM-Newton \n",
"5 INSAT-3BAsiaStar \n",
".. ... \n",
"105 EDRS-C / HYLAS-3[90][91] Intelsat 39[92] \n",
"106 Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96] \n",
"107 Eutelsat Konnect (African Broadband Satellite)... \n",
"108 JCSAT-17GEO-KOMPSAT 2B \n",
"109 Galaxy 30MEV-2BSAT-4b \n",
"\n",
" Payload mass Orbit \\\n",
"# \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 ~6,800 kg GTO \n",
"4 3,800 kg HEO \n",
"5 ~5,800 kg GTO \n",
".. ... ... \n",
"105 10,594 kg GTO \n",
"106 10,495 kg GTO \n",
"107 7,888 kg GTO \n",
"108 9,236 kg GTO \n",
"109 10,468 kg[99]inc 765 kg of support structures. GTO \n",
"\n",
" Customers Launchoutcome \n",
"# \n",
"1 NaN Failure \n",
"2 NaN Partial failure[63] \n",
"3 NaN Success \n",
"4 NaN Success \n",
"5 NaN Success \n",
".. ... ... \n",
"105 ESA Avanti Communications Intelsat Success \n",
"106 InmarsatGovernment of Egypt Success[97] \n",
"107 EutelsatISRO Success \n",
"108 SKY Perfect JSATKARI Success \n",
"109 IntelsatNorthrop GrummanB-SAT Success \n",
"\n",
"[109 rows x 8 columns]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['DateTime (UTC)'] = pd.to_datetime(df['DateTime (UTC)'].str.replace(r'\\[[0-9]+\\]', ''),\n",
" format='%d %B %Y%H:%M', errors='coerce')\n",
"df = df.drop(df[df['DateTime (UTC)'].isnull()].index).set_index('#')\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### What's the difference?\n",
"Now it's time to calculate the difference between consecutive launches. `Numpy` and some smart indexing come to the rescue!"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Flight No.</th>\n",
" <th>DateTime (UTC)</th>\n",
" <th>Rocket typeSerial No.</th>\n",
" <th>Payload</th>\n",
" <th>Payload mass</th>\n",
" <th>Orbit</th>\n",
" <th>Customers</th>\n",
" <th>Launchoutcome</th>\n",
" <th>Time since last mission</th>\n",
" </tr>\n",
" <tr>\n",
" <th>#</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>V-88[62]</td>\n",
" <td>1996-06-04 12:34:00</td>\n",
" <td>G501</td>\n",
" <td>Cluster</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Failure</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>V-101</td>\n",
" <td>1997-10-30 13:43:00</td>\n",
" <td>G502</td>\n",
" <td>MaqSat-H, TEAMSAT, MaqSat-B, YES</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>Partial failure[63]</td>\n",
" <td>513 days 01:09:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>V-112</td>\n",
" <td>1998-10-21 16:37:00</td>\n",
" <td>G503</td>\n",
" <td>MaqSat 3, ARD</td>\n",
" <td>~6,800 kg</td>\n",
" <td>GTO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" <td>356 days 02:54:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>V-119</td>\n",
" <td>1999-12-10 14:32:00</td>\n",
" <td>G504</td>\n",
" <td>XMM-Newton</td>\n",
" <td>3,800 kg</td>\n",
" <td>HEO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" <td>414 days 21:55:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>V-128</td>\n",
" <td>2000-03-21 23:28:00</td>\n",
" <td>G505</td>\n",
" <td>INSAT-3BAsiaStar</td>\n",
" <td>~5,800 kg</td>\n",
" <td>GTO</td>\n",
" <td>NaN</td>\n",
" <td>Success</td>\n",
" <td>102 days 08:56:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>105</th>\n",
" <td>VA-249</td>\n",
" <td>2019-08-06 19:30:00</td>\n",
" <td>ECA5108</td>\n",
" <td>EDRS-C / HYLAS-3[90][91] Intelsat 39[92]</td>\n",
" <td>10,594 kg</td>\n",
" <td>GTO</td>\n",
" <td>ESA Avanti Communications Intelsat</td>\n",
" <td>Success</td>\n",
" <td>46 days 21:47:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>106</th>\n",
" <td>VA-250</td>\n",
" <td>2019-11-26 21:23:00</td>\n",
" <td>ECA5109</td>\n",
" <td>Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96]</td>\n",
" <td>10,495 kg</td>\n",
" <td>GTO</td>\n",
" <td>InmarsatGovernment of Egypt</td>\n",
" <td>Success[97]</td>\n",
" <td>112 days 01:53:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>107</th>\n",
" <td>VA-251</td>\n",
" <td>2020-01-16 21:05:00</td>\n",
" <td>ECA5110</td>\n",
" <td>Eutelsat Konnect (African Broadband Satellite)...</td>\n",
" <td>7,888 kg</td>\n",
" <td>GTO</td>\n",
" <td>EutelsatISRO</td>\n",
" <td>Success</td>\n",
" <td>50 days 23:42:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>108</th>\n",
" <td>VA-252</td>\n",
" <td>2020-02-18 22:18:00</td>\n",
" <td>ECA5111</td>\n",
" <td>JCSAT-17GEO-KOMPSAT 2B</td>\n",
" <td>9,236 kg</td>\n",
" <td>GTO</td>\n",
" <td>SKY Perfect JSATKARI</td>\n",
" <td>Success</td>\n",
" <td>33 days 01:13:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>109</th>\n",
" <td>VA-253</td>\n",
" <td>2020-08-15 22:04:00</td>\n",
" <td>ECA5112</td>\n",
" <td>Galaxy 30MEV-2BSAT-4b</td>\n",
" <td>10,468 kg[99]inc 765 kg of support structures.</td>\n",
" <td>GTO</td>\n",
" <td>IntelsatNorthrop GrummanB-SAT</td>\n",
" <td>Success</td>\n",
" <td>178 days 23:46:00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>109 rows × 9 columns</p>\n",
"</div>"
],
"text/plain": [
" Flight No. DateTime (UTC) Rocket typeSerial No. \\\n",
"# \n",
"1 V-88[62] 1996-06-04 12:34:00 G501 \n",
"2 V-101 1997-10-30 13:43:00 G502 \n",
"3 V-112 1998-10-21 16:37:00 G503 \n",
"4 V-119 1999-12-10 14:32:00 G504 \n",
"5 V-128 2000-03-21 23:28:00 G505 \n",
".. ... ... ... \n",
"105 VA-249 2019-08-06 19:30:00 ECA5108 \n",
"106 VA-250 2019-11-26 21:23:00 ECA5109 \n",
"107 VA-251 2020-01-16 21:05:00 ECA5110 \n",
"108 VA-252 2020-02-18 22:18:00 ECA5111 \n",
"109 VA-253 2020-08-15 22:04:00 ECA5112 \n",
"\n",
" Payload \\\n",
"# \n",
"1 Cluster \n",
"2 MaqSat-H, TEAMSAT, MaqSat-B, YES \n",
"3 MaqSat 3, ARD \n",
"4 XMM-Newton \n",
"5 INSAT-3BAsiaStar \n",
".. ... \n",
"105 EDRS-C / HYLAS-3[90][91] Intelsat 39[92] \n",
"106 Inmarsat-5 F5 (GX 5)[94][95]TIBA-1[96] \n",
"107 Eutelsat Konnect (African Broadband Satellite)... \n",
"108 JCSAT-17GEO-KOMPSAT 2B \n",
"109 Galaxy 30MEV-2BSAT-4b \n",
"\n",
" Payload mass Orbit \\\n",
"# \n",
"1 NaN NaN \n",
"2 NaN NaN \n",
"3 ~6,800 kg GTO \n",
"4 3,800 kg HEO \n",
"5 ~5,800 kg GTO \n",
".. ... ... \n",
"105 10,594 kg GTO \n",
"106 10,495 kg GTO \n",
"107 7,888 kg GTO \n",
"108 9,236 kg GTO \n",
"109 10,468 kg[99]inc 765 kg of support structures. GTO \n",
"\n",
" Customers Launchoutcome \\\n",
"# \n",
"1 NaN Failure \n",
"2 NaN Partial failure[63] \n",
"3 NaN Success \n",
"4 NaN Success \n",
"5 NaN Success \n",
".. ... ... \n",
"105 ESA Avanti Communications Intelsat Success \n",
"106 InmarsatGovernment of Egypt Success[97] \n",
"107 EutelsatISRO Success \n",
"108 SKY Perfect JSATKARI Success \n",
"109 IntelsatNorthrop GrummanB-SAT Success \n",
"\n",
" Time since last mission \n",
"# \n",
"1 NaT \n",
"2 513 days 01:09:00 \n",
"3 356 days 02:54:00 \n",
"4 414 days 21:55:00 \n",
"5 102 days 08:56:00 \n",
".. ... \n",
"105 46 days 21:47:00 \n",
"106 112 days 01:53:00 \n",
"107 50 days 23:42:00 \n",
"108 33 days 01:13:00 \n",
"109 178 days 23:46:00 \n",
"\n",
"[109 rows x 9 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dates = df['DateTime (UTC)'].values\n",
"df['Time since last mission'] = np.insert((dates[1:] - dates[:-1]), 0, None)\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Grand finale\n",
"So what's the final answer?\n",
"> ###### Note:\n",
"> If you were looking for a single smallest difference, `df['Time since last mission'].idxmin()` may be easier."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The minimum time gap between two Ariane 5 launches is 24 days 23:42:00 between V-183 and V-184.\n",
"The minimum time gap between two Ariane 5 launches is 24 days 03:07:00 between VA-243 and VA-245.\n"
]
}
],
"source": [
"idxs = df[df['Time since last mission'].astype('timedelta64[D]') == df['Time since last mission'].astype('timedelta64[D]').min()].index\n",
"for i in idxs:\n",
" diff = df.loc[i, 'Time since last mission']\n",
" prev = df.loc[i-1, 'Flight No.']\n",
" curr = df.loc[i, 'Flight No.']\n",
" print('The minimum time gap between two Ariane 5 launches is ' + str(diff) +\n",
" ' between ' + str(prev) + ' and ' + str(curr) + '.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Done?\n",
"\n",
"> ### Wait - there is [this](https://twitter.com/ArianeGroup/status/1328954863032672259)...\n",
"> [...] there's was a little typo in the question it's between two Ariane missions! 🚀\n",
"\n",
"# 🤷‍♂️"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>1</th>\n",
" <th>Date</th>\n",
" <th>Flight</th>\n",
" <th>Type</th>\n",
" <th>Outcome</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1979-12-24 17:14:00</td>\n",
" <td>L-01</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1980-05-23 14:29:00</td>\n",
" <td>L-02</td>\n",
" <td>Ariane 1</td>\n",
" <td>Failure</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1981-06-19 12:33:00</td>\n",
" <td>L-03</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1981-12-20 01:29:00</td>\n",
" <td>L-04</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1982-09-09 02:12:00</td>\n",
" <td>L-05</td>\n",
" <td>Ariane 1</td>\n",
" <td>Failure</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>248</th>\n",
" <td>2019-08-06 19:30:00</td>\n",
" <td>VA-249</td>\n",
" <td>Ariane 5 ECA 5108</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>249</th>\n",
" <td>2019-11-26 21:23:00</td>\n",
" <td>VA-250</td>\n",
" <td>Ariane 5 ECA 5109</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>250</th>\n",
" <td>2020-01-16 21:05:00</td>\n",
" <td>VA-251</td>\n",
" <td>Ariane 5 ECA5110</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>251</th>\n",
" <td>2020-02-18 22:18:00</td>\n",
" <td>VA-252</td>\n",
" <td>Ariane 5 ECA5111</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" <tr>\n",
" <th>252</th>\n",
" <td>2020-08-15 22:04:00</td>\n",
" <td>VA-253</td>\n",
" <td>Ariane 5 ECA5112</td>\n",
" <td>Success</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>253 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
"1 Date Flight Type Outcome\n",
"0 1979-12-24 17:14:00 L-01 Ariane 1 Success\n",
"1 1980-05-23 14:29:00 L-02 Ariane 1 Failure\n",
"2 1981-06-19 12:33:00 L-03 Ariane 1 Success\n",
"3 1981-12-20 01:29:00 L-04 Ariane 1 Success\n",
"4 1982-09-09 02:12:00 L-05 Ariane 1 Failure\n",
".. ... ... ... ...\n",
"248 2019-08-06 19:30:00 VA-249 Ariane 5 ECA 5108 Success\n",
"249 2019-11-26 21:23:00 VA-250 Ariane 5 ECA 5109 Success\n",
"250 2020-01-16 21:05:00 VA-251 Ariane 5 ECA5110 Success\n",
"251 2020-02-18 22:18:00 VA-252 Ariane 5 ECA5111 Success\n",
"252 2020-08-15 22:04:00 VA-253 Ariane 5 ECA5112 Success\n",
"\n",
"[253 rows x 4 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"urls = [\n",
" 'https://en.wikipedia.org/wiki/List_of_Ariane_launches_(1979%E2%80%931989)',\n",
" 'https://en.wikipedia.org/wiki/List_of_Ariane_launches_(1990%E2%80%931999)',\n",
" 'https://en.wikipedia.org/wiki/List_of_Ariane_launches_(2000%E2%80%932009)',\n",
" 'https://en.wikipedia.org/wiki/List_of_Ariane_launches_(2010%E2%80%932019)',\n",
" 'https://en.wikipedia.org/wiki/List_of_Ariane_launches_(2020%E2%80%932029)'\n",
"]\n",
"\n",
"cdf = None\n",
"\n",
"for url in urls:\n",
" dfs = pd.read_html(url)\n",
" df = dfs[1]\n",
" df.columns = df.loc[1]\n",
" for c in df.columns:\n",
" if c.startswith('Date'):\n",
" date_column = c\n",
" if c.startswith('Serial') or c.startswith('Flight'):\n",
" flight_column = c\n",
" if c.startswith('Variant'):\n",
" type_column = c\n",
" if c.startswith('Configuration'):\n",
" conf_column = c\n",
" if c.startswith('Rocket type'):\n",
" type_column = c\n",
" conf_column = c\n",
" if 'outcome' in c or 'Outcome' in c:\n",
" out_column = c\n",
" \n",
" df['Date'] = pd.to_datetime(df[date_column].str.replace(r'\\[[0-9]+\\]', '').str.replace(r'[ ,]', ''),\n",
" format='%d%B%Y%H:%M', errors='coerce')\n",
" df.loc[df['Date'].isnull(), 'Date'] = pd.to_datetime(\n",
" df[date_column].str.replace(r'\\[[0-9]+\\]', '').str.replace(r'[ ,]', ''),\n",
" format='%d%B%Y%H:%M:%S', errors='coerce')\n",
" #df.loc[df['Date'].isnull(), 'Date'] = df['Date_s']\n",
" df['Flight'] = df[flight_column].str.replace(r'\\[[0-9]+\\]', '')\n",
" if type_column == conf_column:\n",
" df['Type'] = df[type_column].str.replace(r'\\[[0-9]+\\]', '')\n",
" else:\n",
" df['Type'] = df[type_column].str.replace(r'\\[[0-9]+\\]', '')\n",
" df.loc[~df[conf_column].isnull(), 'Type'] = df['Type'] + ' ' + df[conf_column].str.replace(r'\\[[0-9]+\\]', '')\n",
" df['Outcome'] = df[out_column].str.replace(r'\\[[0-9]+\\]', '')\n",
" df = df.drop(df[df['Date'].isnull()].index)\n",
" \n",
" if cdf is None:\n",
" cdf = df[['Date', 'Flight', 'Type', 'Outcome']]\n",
" else:\n",
" cdf = cdf.append(df[['Date', 'Flight', 'Type', 'Outcome']])\n",
" \n",
"df = cdf.sort_values('Date').reset_index(drop=True)\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>1</th>\n",
" <th>Date</th>\n",
" <th>Flight</th>\n",
" <th>Type</th>\n",
" <th>Outcome</th>\n",
" <th>Time since last mission</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1979-12-24 17:14:00</td>\n",
" <td>L-01</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" <td>NaT</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1980-05-23 14:29:00</td>\n",
" <td>L-02</td>\n",
" <td>Ariane 1</td>\n",
" <td>Failure</td>\n",
" <td>150 days 21:15:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1981-06-19 12:33:00</td>\n",
" <td>L-03</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" <td>391 days 22:04:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>1981-12-20 01:29:00</td>\n",
" <td>L-04</td>\n",
" <td>Ariane 1</td>\n",
" <td>Success</td>\n",
" <td>183 days 12:56:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>1982-09-09 02:12:00</td>\n",
" <td>L-05</td>\n",
" <td>Ariane 1</td>\n",
" <td>Failure</td>\n",
" <td>263 days 00:43:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>248</th>\n",
" <td>2019-08-06 19:30:00</td>\n",
" <td>VA-249</td>\n",
" <td>Ariane 5 ECA 5108</td>\n",
" <td>Success</td>\n",
" <td>46 days 21:47:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>249</th>\n",
" <td>2019-11-26 21:23:00</td>\n",
" <td>VA-250</td>\n",
" <td>Ariane 5 ECA 5109</td>\n",
" <td>Success</td>\n",
" <td>112 days 01:53:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>250</th>\n",
" <td>2020-01-16 21:05:00</td>\n",
" <td>VA-251</td>\n",
" <td>Ariane 5 ECA5110</td>\n",
" <td>Success</td>\n",
" <td>50 days 23:42:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>251</th>\n",
" <td>2020-02-18 22:18:00</td>\n",
" <td>VA-252</td>\n",
" <td>Ariane 5 ECA5111</td>\n",
" <td>Success</td>\n",
" <td>33 days 01:13:00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>252</th>\n",
" <td>2020-08-15 22:04:00</td>\n",
" <td>VA-253</td>\n",
" <td>Ariane 5 ECA5112</td>\n",
" <td>Success</td>\n",
" <td>178 days 23:46:00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>253 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
"1 Date Flight Type Outcome \\\n",
"0 1979-12-24 17:14:00 L-01 Ariane 1 Success \n",
"1 1980-05-23 14:29:00 L-02 Ariane 1 Failure \n",
"2 1981-06-19 12:33:00 L-03 Ariane 1 Success \n",
"3 1981-12-20 01:29:00 L-04 Ariane 1 Success \n",
"4 1982-09-09 02:12:00 L-05 Ariane 1 Failure \n",
".. ... ... ... ... \n",
"248 2019-08-06 19:30:00 VA-249 Ariane 5 ECA 5108 Success \n",
"249 2019-11-26 21:23:00 VA-250 Ariane 5 ECA 5109 Success \n",
"250 2020-01-16 21:05:00 VA-251 Ariane 5 ECA5110 Success \n",
"251 2020-02-18 22:18:00 VA-252 Ariane 5 ECA5111 Success \n",
"252 2020-08-15 22:04:00 VA-253 Ariane 5 ECA5112 Success \n",
"\n",
"1 Time since last mission \n",
"0 NaT \n",
"1 150 days 21:15:00 \n",
"2 391 days 22:04:00 \n",
"3 183 days 12:56:00 \n",
"4 263 days 00:43:00 \n",
".. ... \n",
"248 46 days 21:47:00 \n",
"249 112 days 01:53:00 \n",
"250 50 days 23:42:00 \n",
"251 33 days 01:13:00 \n",
"252 178 days 23:46:00 \n",
"\n",
"[253 rows x 5 columns]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dates = df['Date'].values\n",
"df['Time since last mission'] = np.insert((dates[1:] - dates[:-1]), 0, None)\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The minimum time gap between two Ariane launches is 5 days 22:49:00 between V-135 (Ariane 5 G 507) and V-136 (Ariane 4 44L-3 4102).\n",
"The minimum time gap between two Ariane launches is 5 days 18:08:00 between V-148 (Ariane 4 44L 4109) and V-145 (Ariane 5 G 511).\n"
]
}
],
"source": [
"idxs = df[df['Time since last mission'].astype('timedelta64[D]') == df['Time since last mission'].astype('timedelta64[D]').min()].index\n",
"for i in idxs:\n",
" diff = df.loc[i, 'Time since last mission']\n",
" prev = df.loc[i-1, 'Flight']\n",
" prev_type = df.loc[i-1, 'Type']\n",
" curr = df.loc[i, 'Flight']\n",
" curr_type = df.loc[i, 'Type']\n",
" print('The minimum time gap between two Ariane launches is ' + str(diff) +\n",
" ' between ' + str(prev) + ' (' + prev_type + ') and ' + \n",
" str(curr) + ' (' + curr_type + ').')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Q.E.D."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment