CoolFace
Apppublic

Orangefish/project

sourceHugging Faceupdated 4y agoView on Hugging Face
0likes
functions.py63 linesDownload Raw Back to root
1from datetime import datetime2import requests3import os4import joblib5import pandas as pd6import json7 8 9 10 11def get_weather_by_date(date):12    return requests.get(f'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/helsinki/{date}?unitGroup=metric&include=days&key=J7TT2WGMUNNHD8JBEDXAJJXB2&contentType=json').json()13 14 15def get_weather_df(data):16    col_names = [17        'name',18        'datetime',19        'tempmax',20        'tempmin',21        'temp',22        'feelslikemax',23        'feelslikemin',24        'feelslike',25        'dew',26        'humidity',27        'precip',28        'precipprob',29        'precipcover',30        'snow',31        'snowdepth',32        'windgust',33        'windspeed',34        'winddir',35        'sealevelpressure',36        'cloudcover',37        'visibility',38        'solarradiation',39        'solarenergy',40        'uvindex',41        'conditions'42    ]43 44    45 46    new_data = pd.DataFrame(47        data,48        columns=col_names49    )50    new_data.datetime = new_data.datetime.apply(timestamp_2_time1)51    #new_data.rename(columes={'pressure':'sealevelpressure'})52    return new_data53 54def timestamp_2_time1(x):55    dt_obj = datetime.strptime(str(x), '%Y-%m-%d')56    dt_obj = dt_obj.timestamp() * 100057    return int(dt_obj)58 59def timestamp_2_time(x):60    dt_obj = datetime.strptime(str(x), '%m/%d/%Y')61    dt_obj = dt_obj.timestamp() * 100062    return int(dt_obj)63