How can I , if possible, carry the end part of the code shown below, over onto another line(s) or alter the text, to achieve the desired outcome, with less code. I have typed the following code:
import pandas as pd
import requests
from bs4 import BeautifulSoup
res = requests.get("http://web.archive.org/web/20070826230746/http://www.bbmf.co.uk/july07.html")
soup = BeautifulSoup(res.content,'lxml')
table = soup.find_all('table')[0]
df = pd.read_html(str(table))
df = df[1]
df = df.rename(columns=df.iloc[0])
df = df.iloc[2:]
df.head(15)
Southport = df[df['Location'].str.contains('- Display') & (df['Lancaster'] == '') & (df['Dakota'] == 'D') & (df['Spitfire'] == 'S') & (df['Hurricane'] == 'H') | (df[df['Location'].str.contains('- Display') & (df['Lancaster'] == '') & (df['Dakota'] == 'D') & (df['Spitfire'] == 'S') | df[df['Location'].str.contains('- Display') & (df['Lancaster'] == '') & (df['Dakota'] == 'D') & (df['Spitfire'] == 'SS')]
Southport
What I am trying to achieve is the following Data to be shown :- Displays only, and only showing Dakota Spitfire and Hurricane or Dakota and Spitfire or Dakota and Two Spitfires, if they are shown in the Data Table Schedule, here is the whole Code. It is the line starting Southport = that needs editing:
I get the following Traceback Error when I run the Code, which I believe is due to the line of code being too long:
File "<ipython-input-1-518a9f1c8e98>", line 23
Southport
^
SyntaxError: invalid syntax
I am running the code in the internet program Jupyter Notebook