Posts: 218
Threads: 27
Joined: May 2018
Jun-15-2019, 03:04 PM
(This post was last modified: Jun-15-2019, 03:04 PM by eddywinch82.)
Hi There,
I am trying to Tabulate Information from an RAF Aircraft Website Schedule.
I would like only the appearances, that are displays, and only showing those, that have the Spitfire Hurricane and Dakota booked, in table form. Either for each Individual month, or for the year as a whole i.e. 2007.
For example for September the Website Link is :-
http://web.archive.org/web/2007070113381...ber07.html
And each of the Months Website Link is different, by only the month name i.e. march07.html
august07.html etc.
Can someone help me with my code :-
I used the September Website Link as an attempt, to tabulate the Webpage Data. But the data didn't display correctly, when I ran the Code, any help would be much appreciated.
Here is the Code :-
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') ) Regards
Eddie Winch
Posts: 7,324
Threads: 123
Joined: Sep 2016
Jun-16-2019, 02:39 AM
(This post was last modified: Jun-16-2019, 02:39 AM by snippsat.)
So it's still Aircrafts eddy
And i guess still little Python.
You are mixing up some stuff here,drop tabulate and do all in pandas.
You pretty much need Jupyter Notebook,this make display of table and testing a whole lot simpler.
I have done some testing look at this notebook
See that display of table is good in notebook.
Done some comparing,all Location that had Spitfire in program.
df = df[(df['Location'] != "") & (df['Spitfire'] == 'S')] So in September had Boston two display of Spitfire.
df[(df['Location'] == 'Boston') & (df['Spitfire'] == 'S')] Output: Location Spitfire
57 Boston S
76 Boston S
Posts: 218
Threads: 27
Joined: May 2018
Jun-16-2019, 12:25 PM
(This post was last modified: Jun-16-2019, 08:34 PM by eddywinch82.)
Many thanks for your help snippsat,
I only want to the table to show the Venues, having displays, and that have the Spitfire Hurricane and Dakota booked,I want all the others not to be shown. Also how could I have a Table just showing, all of the Spitfire Hurricane and Dakota booked displays i.e. SHD only, for the whole year, altogether ?
Regards
Eddie Winch
Posts: 218
Threads: 27
Joined: May 2018
Also how do you get Jupyter working ? I am not sure how to use it ?
Posts: 7,324
Threads: 123
Joined: Sep 2016
Jun-16-2019, 10:14 PM
(This post was last modified: Jun-16-2019, 10:14 PM by snippsat.)
(Jun-16-2019, 08:31 PM)eddywinch82 Wrote: Also how do you get Jupyter working ? I am not sure how to use it ? Installing Jupyter
I think you used Windows.
# Check pip
G:\1_bilder\forum
λ pip -V
pip 19.1.1 from c:\python37\lib\site-packages\pip (python 3.7)
# Install
G:\1_bilder\forum
λ pip install jupyter
Collecting jupyter
Downloading .....
# Start Notebook
G:\1_bilder\forum
λ jupyter notebook Try get up and running,see if understand how i get filtered result for September.
For whole year most loop over pages and collect wanted result.
Posts: 218
Threads: 27
Joined: May 2018
Jun-17-2019, 12:58 PM
(This post was last modified: Jun-17-2019, 01:13 PM by eddywinch82.)
Hi snippsat,
I finally got Jupyter Notebook, working last night. How do you run Python Code, in Jupyter Notebook ?
df = df[(df['Location'] != "") & (df['Spitfire'] == 'S')] The above Code you typed for me, is showing all Locations, that have a Spitfire booked.
What would I type, to only show all Locations, that were having displays only i.e. Lydd - Display. And that only, had the Spitfire Hurricane and Dakota booked. I can see what you are doing there, in the coding. When typing the whole code, is it typed in the order, it is displayed as, in your Notebook ?
Eddie
Many thanks buran, for sorting that out for me.
Posts: 7,324
Threads: 123
Joined: Sep 2016
Jun-17-2019, 03:54 PM
(This post was last modified: Jun-17-2019, 03:54 PM by snippsat.)
(Jun-17-2019, 12:58 PM)eddywinch82 Wrote: I finally got Jupyter Notebook, working last night. How do you run Python Code, in Jupyter Notebook ? When it start in browser,image under choice python 3.
Quote:When typing the whole code, is it typed in the order, it is displayed as, in your Notebook ?
Yes run one cell and display output.
Quote:What would I type, to only show all Locations, that were having displays only i.e. Lydd - Display. And that only, had the Spitfire Hurricane and Dakota booked.
Look at this Notebook.
Here you get a clean up Dataframe and can do test with data as i show under.
Is your task so now that you have gotten start help show some effort,i am not gone write all code
Search for tutorials Pandas/NoteBook there are a lot out there.
Posts: 218
Threads: 27
Joined: May 2018
Thanks for your help snippsat,
I have a problem, where when I copy text, and try to Paste the Text, in a new Jupyter Notebook, Python3 Section Cell, the option to Paste is greyed out. Is there a way of fixing this ? Did you have the same issue ? According to posts on the internet, other people have had the same problem.
Eddie
Posts: 7,324
Threads: 123
Joined: Sep 2016
Jun-17-2019, 06:29 PM
(This post was last modified: Jun-17-2019, 06:29 PM by snippsat.)
(Jun-17-2019, 06:01 PM)eddywinch82 Wrote: I have a problem, where when I copy text, and try to Paste the Text, in a new Jupyter Notebook, Python3 Section Cell, the option to Paste is greyed out. Are you taking about my Notebook?
That's a static Notebook made with nbviewer only for share code/data.
The field will be greyed as you it's only a Notebook for display of what i have done.
You have to copy content over to your Notebook and run it.
Posts: 218
Threads: 27
Joined: May 2018
"You have to copy content over to your Notebook and run it."
Thats what I tried to do, I meant copying text, and trying to paste in a new Notebook, in Jupyter Notebook but the option to paste text is greyed out.
Eddie
|