naohiro701 commited on
Commit
8afa4e1
·
verified ·
1 Parent(s): 07201c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -29,6 +29,9 @@ def get_renewable_energy_data(city_code):
29
  base_times = data[next(iter(data))]['x']
30
  result_df = pd.DataFrame({"Time": base_times})
31
 
 
 
 
32
  # Loop through each energy type and append hourly capacity factor data to the DataFrame
33
  for energy_type, energy_data in data.items():
34
  if 'x' in energy_data and 'y' in energy_data:
@@ -168,6 +171,7 @@ def optimize_energy_system(city_code, solar_cost, onshore_wind_cost, offshore_wi
168
  heatmaps = []
169
  for energy_source in ['solar', 'onshore_wind', 'offshore_wind', 'river']:
170
  df_heatmap = data[['Time', f'{energy_source} hourly capacity factor']].copy()
 
171
  df_heatmap['day_of_year'] = df_heatmap['Time'].dt.dayofyear
172
  df_heatmap['hour_of_day'] = df_heatmap['Time'].dt.hour
173
 
 
29
  base_times = data[next(iter(data))]['x']
30
  result_df = pd.DataFrame({"Time": base_times})
31
 
32
+ # Convert 'Time' column to datetime
33
+ result_df['Time'] = pd.to_datetime(result_df['Time'], errors='coerce')
34
+
35
  # Loop through each energy type and append hourly capacity factor data to the DataFrame
36
  for energy_type, energy_data in data.items():
37
  if 'x' in energy_data and 'y' in energy_data:
 
171
  heatmaps = []
172
  for energy_source in ['solar', 'onshore_wind', 'offshore_wind', 'river']:
173
  df_heatmap = data[['Time', f'{energy_source} hourly capacity factor']].copy()
174
+ df_heatmap['Time'] = pd.to_datetime(df_heatmap['Time'], errors='coerce') # Ensure Time is in datetime format
175
  df_heatmap['day_of_year'] = df_heatmap['Time'].dt.dayofyear
176
  df_heatmap['hour_of_day'] = df_heatmap['Time'].dt.hour
177