I want to tabulate and store into Pandas this linked data from the U.S. Weather Service.
Here are the first four lines of the webpage.
Historic Crests
(1) 43.28 ft on 04/17/1979
(2) 39.58 ft on 05/25/1983
(3) 36.67 ft on 02/17/2020
You can access the data from an IDE or notebook using the following code.
import bs4
import urllib.request
link = "https://water.weather.gov/ahps2/crests.php?wfo=jan&gage=jacm6&crest_type=historic"
webpage=str(urllib.request.urlopen(link).read())
soup = bs4.BeautifulSoup(webpage)
print(soup.get_text())
The data is already in a table-like structure, and I think you could tabulate it by parsing it into a dictionary of lists and then uploading it into a Pandas Dataframe. However, I imagine that there is a more simple pythonic approach.
Here's a snippet of the desired table structure.
| No. | Crest | Date |
|---|---|---|
| 1 | 43.28 | 04/17/1979 |
| 2 | 39.58 | 05/25/1983 |
| 3 | 36.67 | 02/17/2020 |