Spaces:
Runtime error
Runtime error
Orangefish
commited on
Commit
•
8e7dace
1
Parent(s):
f6da296
Update functions.py
Browse files- functions.py +1 -61
functions.py
CHANGED
@@ -8,69 +8,9 @@ import json
|
|
8 |
|
9 |
|
10 |
|
11 |
-
def
|
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 |
-
def get_air_quality_data():
|
15 |
-
|
16 |
-
AIR_QUALITY_API_KEY = os.getenv('AIR_QUALITY_API_KEY')
|
17 |
-
json = get_air_json(AIR_QUALITY_API_KEY)
|
18 |
-
iaqi = json['iaqi']
|
19 |
-
forecast = json['forecast']['daily']
|
20 |
-
return [
|
21 |
-
json['aqi'], # AQI
|
22 |
-
json['time']['s'][:10], # Date
|
23 |
-
iaqi['h']['v'],
|
24 |
-
iaqi['p']['v'],
|
25 |
-
iaqi['pm10']['v'],
|
26 |
-
iaqi['t']['v'],
|
27 |
-
forecast['o3'][0]['avg'],
|
28 |
-
forecast['o3'][0]['max'],
|
29 |
-
forecast['o3'][0]['min'],
|
30 |
-
forecast['pm10'][0]['avg'],
|
31 |
-
forecast['pm10'][0]['max'],
|
32 |
-
forecast['pm10'][0]['min'],
|
33 |
-
forecast['pm25'][0]['avg'],
|
34 |
-
forecast['pm25'][0]['max'],
|
35 |
-
forecast['pm25'][0]['min'],
|
36 |
-
forecast['uvi'][0]['avg'],
|
37 |
-
forecast['uvi'][0]['avg'],
|
38 |
-
forecast['uvi'][0]['avg']
|
39 |
-
]
|
40 |
-
|
41 |
-
|
42 |
-
def get_weather_data(json):
|
43 |
-
#WEATHER_API_KEY = os.getenv('WEATHER_API_KEY')
|
44 |
-
|
45 |
-
#csv = get_weather_csv()
|
46 |
-
data = json['days'][0]
|
47 |
-
print("data parsed sccessfully")
|
48 |
-
#return [
|
49 |
-
# #json['address'].capitalize(),
|
50 |
-
# data['datetime'],
|
51 |
-
# data['feelslikemax'],
|
52 |
-
# data['feelslikemin'],
|
53 |
-
# data['feelslike'],
|
54 |
-
# data['dew'],
|
55 |
-
# data['humidity'],
|
56 |
-
# data['precip'],
|
57 |
-
# data['precipprob'],
|
58 |
-
# data['precipcover'],
|
59 |
-
# data['snow'],
|
60 |
-
# data['snowdepth'],
|
61 |
-
# data['windgust'],
|
62 |
-
# data['windspeed'],
|
63 |
-
# data['winddir'],
|
64 |
-
# data['pressure'],
|
65 |
-
# data['cloudcover'],
|
66 |
-
# data['visibility'],
|
67 |
-
# data['solarradiation'],
|
68 |
-
# data['solarenergy'],
|
69 |
-
# data['uvindex'],
|
70 |
-
# data['conditions']
|
71 |
-
#]
|
72 |
-
return data
|
73 |
-
|
74 |
|
75 |
def get_weather_df(data):
|
76 |
col_names = [
|
|
|
8 |
|
9 |
|
10 |
|
11 |
+
def 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 |
|
15 |
def get_weather_df(data):
|
16 |
col_names = [
|