Spaces:
Runtime error
Runtime error
File size: 1,396 Bytes
baa2a05 ae61035 baa2a05 d30adf0 baa2a05 ae61035 516120f baa2a05 ae61035 baa2a05 b05c6d2 5eeb54f 516120f 5eeb54f 0355558 5eeb54f ae61035 b781e81 0355558 ad8cd91 5eeb54f 3cacb36 516120f 993687c f906b11 1946134 5eeb54f 65b8045 f906b11 0355558 3cacb36 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 19feb2023
#https://huggingface.co/spaces/keras-io/timeseries_forecasting_for_weather/
import streamlit as st
import datetime
import pandas as pd
import numpy as np
backlogmax = 4
today = datetime.date.today()
ayear = int(today.strftime("%Y"))-0
amonth = int(today.strftime("%m"))
amonthday = int(today.strftime("%d"))
st.write(type(ayear))
st.write(("{}-{}-{}").format(ayear,amonth,amonthday))
adf = pd.DataFrame(columns=["Date Time","p (mbar)","T (degC)","Tpot (K)","Tdew (degC)","rh (%)","VPmax (mbar)","VPact (mbar)","VPdef (mbar)","sh (g/kg)","H2OC (mmol/mol)","rho (g/m**3)","wv (m/s)","max. wv (m/s)","wd (deg)"])
for i in range(ayear-backlogmax,ayear,1):
alink = ("https://data.weather.gov.hk/weatherAPI/opendata/opendata.php?dataType=CLMTEMP&year={}&rformat=csv&station=HKO").format(str(i))
df = pd.read_csv(alink, skiprows=[0,1,2], skipfooter=3, engine='python', on_bad_lines='skip')
st.write(i)
nparray = np.array([])
df = df.reset_index() # make sure indexes pair with number of rows
for index, row in df.iterrows():
if (row[2]!=amonth) or (row[3]!=amonthday):
continue
st.write(row[0],row[1],row[2],row[3],row[4],amonth,amonthday)
adate = ("{}.{}.{} 00:00:00").format(row[2], row[1], row[0])
nparray = np.vstack(np.array([adate,"",row[4],"","","","","","","","","","","",""]))
break
adf = pd.concat([adf, pd.DataFrame(nparray)], axis=0)
st.dataframe(adf) |