Pattr commited on
Commit
9f3eed6
·
verified ·
1 Parent(s): 52fc559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -34,13 +34,15 @@ def get_dataset():
34
  _query = "SELECT id , ds ,a_temp ,m_temp ,n_temp ,y ,a_pres ,m_pres ,a_ws ,m_ws ,a_humi ,m_humi ,n_humi ,a_vis flat,m_vis ,n_vis FROM weather_new"
35
  _cursor.execute(_query)
36
  _data = cursor.fetchall()
 
 
37
  _df = pd.DataFrame(_data,columns=['id','ds','a_temp','m_temp','n_temp','y','a_pres','m_pres','a_ws','m_ws','a_humi','m_humi','n_humi' ,'a_vis','m_vis' ,'n_vis']).drop('id',axis=1)
38
  return _df
39
 
40
 
41
  places = get_data()
42
  places.replace({'indoor ': 'indoor', 'outdoor ': 'outdoor'}, inplace=True)
43
- places = places[(places['province'] == province) & (places['a_type'] == activity) & (places['genre'] == purpose.lower())]
44
  province_mapping = {
45
  'Bangkok': 'กรุงเทพฯ',
46
  'Nakohn Pathom': 'นครปฐม',
@@ -74,7 +76,7 @@ def get_advice(province, activity, purpose, year, month, date):
74
  activity = 'indoor' if is_rain else activity.lower()
75
 
76
  province = province_mapping[province]
77
-
78
 
79
 
80
  random_idx = np.random.randint(0, len(places))
 
34
  _query = "SELECT id , ds ,a_temp ,m_temp ,n_temp ,y ,a_pres ,m_pres ,a_ws ,m_ws ,a_humi ,m_humi ,n_humi ,a_vis flat,m_vis ,n_vis FROM weather_new"
35
  _cursor.execute(_query)
36
  _data = cursor.fetchall()
37
+ _cursor.close()
38
+ _conn.close()
39
  _df = pd.DataFrame(_data,columns=['id','ds','a_temp','m_temp','n_temp','y','a_pres','m_pres','a_ws','m_ws','a_humi','m_humi','n_humi' ,'a_vis','m_vis' ,'n_vis']).drop('id',axis=1)
40
  return _df
41
 
42
 
43
  places = get_data()
44
  places.replace({'indoor ': 'indoor', 'outdoor ': 'outdoor'}, inplace=True)
45
+
46
  province_mapping = {
47
  'Bangkok': 'กรุงเทพฯ',
48
  'Nakohn Pathom': 'นครปฐม',
 
76
  activity = 'indoor' if is_rain else activity.lower()
77
 
78
  province = province_mapping[province]
79
+ places = places[(places['province'] == province) & (places['a_type'] == activity) & (places['genre'] == purpose.lower())]
80
 
81
 
82
  random_idx = np.random.randint(0, len(places))