import pandas as pd
import requests
from bs4 import BeautifulSoup
#from tabulate import tabulate
res = requests.get("http://web.archive.org/web/20070701133815/http://www.bbmf.co.uk/september07.html")
soup = BeautifulSoup(res.content,'lxml')
table = soup.find_all('table')[0]
df = pd.read_html(str(table))
#print( tabulate(df[0], headers='keys', tablefmt='psql') )
# Clean up,put index(Date location...) at top,delete 2 first row
df = df[1]
df = df.rename(columns=df.iloc[0])
df = df.iloc[2:]
df.head(15)
Date | Location | Lancaster | Spitfire | Hurricane | Dakota | |
---|---|---|---|---|---|---|
2 | 1 | Fort Nelson | NaN | S | NaN | NaN |
3 | NaN | Lydd - Display | L | S | H | NaN |
4 | NaN | Shackerstone - Display | NaN | S | NaN | NaN |
5 | NaN | Rye Meadows | NaN | S | NaN | NaN |
6 | NaN | Alfrick | NaN | S | NaN | NaN |
7 | 2 | Lydd - Display | L | S | H | NaN |
8 | NaN | Chart Sutton | NaN | S | H | NaN |
9 | NaN | Gedling | NaN | S | H | NaN |
10 | NaN | Ludford Magna | L | NaN | NaN | NaN |
11 | NaN | Elvington | NaN | NaN | NaN | D |
12 | NaN | Headingly Campus | NaN | NaN | NaN | D |
13 | NaN | Darley | L | S | NaN | NaN |
14 | 7 | RAF Wittering | NaN | S | NaN | NaN |
15 | NaN | RAF Honington | NaN | S | NaN | NaN |
16 | NaN | RAF Leeming | NaN | S | NaN | NaN |
# Lydd - Display. And that only, had the Spitfire Hurricane and Dakota booked
# Here Lydd -- Spitfire Hurricane,there where none where all where booked
lydd = df[(df['Lancaster'] == "L") & (df['Spitfire'] == 'S') & (df['Hurricane'] == 'H')]
lydd
Date | Location | Lancaster | Spitfire | Hurricane | Dakota | |
---|---|---|---|---|---|---|
3 | NaN | Lydd - Display | L | S | H | NaN |
7 | 2 | Lydd - Display | L | S | H | NaN |
24 | NaN | Duxford - Display | L | S | H | NaN |
29 | NaN | Duxford - Display | L | S | H | NaN |
52 | 15 | Middle Wallop - Display | L | S | H | NaN |
53 | NaN | Shoreham - Display | L | S | H | NaN |
56 | NaN | Chichester | L | S | H | NaN |
66 | NaN | Shoreham - Display | L | S | H | NaN |
# Here with "or" | Hurricane
lydd = df[(df['Lancaster'] == "L") & (df['Spitfire'] == 'S') & (df['Hurricane'] == 'H') | (df['Hurricane'] == 'H')]
lydd
Date | Location | Lancaster | Spitfire | Hurricane | Dakota | |
---|---|---|---|---|---|---|
3 | NaN | Lydd - Display | L | S | H | NaN |
7 | 2 | Lydd - Display | L | S | H | NaN |
8 | NaN | Chart Sutton | NaN | S | H | NaN |
9 | NaN | Gedling | NaN | S | H | NaN |
24 | NaN | Duxford - Display | L | S | H | NaN |
25 | NaN | Faldingworth | NaN | S | H | NaN |
26 | NaN | Donington Park | NaN | S | H | NaN |
27 | NaN | Cliveden | NaN | S | H | NaN |
29 | NaN | Duxford - Display | L | S | H | NaN |
31 | NaN | Cliveden | NaN | S | H | NaN |
32 | NaN | Kemble - Display | NaN | S | H | NaN |
33 | NaN | Donington Park | NaN | S | H | NaN |
40 | 12 | Odiham | NaN | S | H | D |
42 | 13 | Guernsey - Display | NaN | S | H | D |
43 | NaN | Jersey - Display | NaN | S | H | D |
52 | 15 | Middle Wallop - Display | L | S | H | NaN |
53 | NaN | Shoreham - Display | L | S | H | NaN |
56 | NaN | Chichester | L | S | H | NaN |
61 | NaN | Bentley Priory - Display | NaN | S | H | NaN |
62 | NaN | Little Casterton | NaN | S | H | NaN |
66 | NaN | Shoreham - Display | L | S | H | NaN |
67 | NaN | Newhaven Fort | NaN | S | H | NaN |
68 | NaN | Staplehurst | NaN | S | H | NaN |
69 | NaN | Weald of Kent | NaN | S | H | NaN |
86 | NaN | Hanley Stoke on Trent | NaN | S | H | D |
87 | NaN | Southport - Display | NaN | S | H | D |
88 | 23 | Southport - Display | NaN | S | H | D |