Created
July 24, 2023 17:56
-
-
Save john-adeojo/13ae233ecfb25aa6908ae834ef16ef53 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import numpy as np | |
def temp_model(date): | |
""" | |
Converts a date to a number. | |
Parameters: | |
date (str): The date in 'YYYY-MM-DD' format. | |
Returns: | |
float: The temperature. | |
""" | |
random = np.random.uniform(1, 2) | |
timestamp = pd.to_datetime(date).timestamp() | |
temperature = np.round(np.log(timestamp) * np.log(random), 2) | |
return temperature | |
def get_temperature(location, date): | |
""" | |
Modeling a weather API. | |
Get the temperature for a given location, | |
at a given date and in a given | |
""" | |
temerature = temp_model(date) | |
news_round = { | |
"location": location, | |
"date": date, | |
"temerature": temerature, | |
"scale": "Farenheit" | |
} | |
return json.dumps(news_round) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment