a10 commited on
Commit
e5adb55
·
1 Parent(s): bba8de4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
  import streamlit as st
4
  import pandas as pd
5
  import numpy as np
@@ -36,10 +34,18 @@ def asubmit(aparam):
36
  aparam["acontainer"].map(adf3)
37
 
38
  abacklogmax = 10
 
 
 
 
 
39
  atoday = datetime.date.today()
40
  ayear = int(atoday.strftime("%Y"))-0
41
  amonth = int(atoday.strftime("%m"))
42
  amonthday = int(atoday.strftime("%d"))
 
 
 
43
  atitles = aparam["acolumntitles"]
44
 
45
  csvString = ""
@@ -62,13 +68,13 @@ def asubmit(aparam):
62
  adf3 = pd.read_csv(StringIO(csvString), sep=",")
63
  aparam["acontainer"].dataframe(adf3)
64
 
 
65
  from sklearn.linear_model import LinearRegression
66
- # Creating a Linear Regression model on our data
67
- lin = LinearRegression()
68
- lin.fit(adf3[['Date']].astype('float').astype('int32'), adf3['Celsius'])
69
 
70
  atrendproject = [20230223,]
71
- st.dataframe(pd.merge(pd.DataFrame([atrendproject]), pd.DataFrame(lin.predict(np.array([atrendproject]))), left_index=True, right_index=True))
72
 
73
  adf = pd.DataFrame(
74
  astations,
 
 
 
1
  import streamlit as st
2
  import pandas as pd
3
  import numpy as np
 
34
  aparam["acontainer"].map(adf3)
35
 
36
  abacklogmax = 10
37
+
38
+ atimezone = os.environ['TZ']
39
+ # os.environ['TZ'] = 'Europe/London'
40
+ os.environ['TZ'] = 'Asia/Hong Kong'
41
+ time.tzset()
42
  atoday = datetime.date.today()
43
  ayear = int(atoday.strftime("%Y"))-0
44
  amonth = int(atoday.strftime("%m"))
45
  amonthday = int(atoday.strftime("%d"))
46
+ os.environ['TZ'] = atimezone
47
+ time.tzset()
48
+
49
  atitles = aparam["acolumntitles"]
50
 
51
  csvString = ""
 
68
  adf3 = pd.read_csv(StringIO(csvString), sep=",")
69
  aparam["acontainer"].dataframe(adf3)
70
 
71
+ # Trend projection for same date of current year with past year references of same date
72
  from sklearn.linear_model import LinearRegression
73
+ lr = LinearRegression()
74
+ lr.fit(adf3[['Date']].astype('float').astype('int32'), adf3['Celsius'])
 
75
 
76
  atrendproject = [20230223,]
77
+ st.dataframe(pd.merge(pd.DataFrame([atrendproject]), pd.DataFrame(lr.predict(np.array([atrendproject]))), left_index=True, right_index=True))
78
 
79
  adf = pd.DataFrame(
80
  astations,