Last active
October 26, 2022 09:36
-
-
Save kwinkunks/5dafc61b7d67f2133035908af47c0b51 to your computer and use it in GitHub Desktop.
Get earthquakes on your birthday
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from datetime import timedelta | |
from urllib.parse import urlencode | |
def birthquakes(birthday:str) -> pd.DataFrame: | |
""" | |
Make a DataFrame of earthquakes on a given day. | |
Example: birthquake("1971-05-26") | |
""" | |
birthday = pd.to_datetime(birthday) | |
url = 'https://earthquake.usgs.gov/fdsnws/event/1/query' | |
query = { | |
'format': 'csv', | |
'starttime': birthday, | |
'endtime': birthday + timedelta(days=1), | |
} | |
return pd.read_csv(f"{url}?{urlencode(query)}") | |
birthquakes('26 May 1971') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment