Skip to content

Instantly share code, notes, and snippets.

@john-adeojo
Created July 24, 2023 17:56
Show Gist options
  • Save john-adeojo/13ae233ecfb25aa6908ae834ef16ef53 to your computer and use it in GitHub Desktop.
Save john-adeojo/13ae233ecfb25aa6908ae834ef16ef53 to your computer and use it in GitHub Desktop.
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