update generate data code
This commit is contained in:
		
							
								
								
									
										41688
									
								
								combined_data.csv
									
									
									
									
									
								
							
							
						
						
									
										41688
									
								
								combined_data.csv
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										22
									
								
								read_data.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								read_data.py
									
									
									
									
									
								
							| @@ -2,39 +2,27 @@ import pandas as pd | |||||||
| import numpy as np | import numpy as np | ||||||
| import csv | import csv | ||||||
|  |  | ||||||
| pv_yield_file_name = 'read_data/Riyahd.csv' | pv_yield_file_name = 'read_data/Serbia.csv' | ||||||
| factory_demand_file_name = 'factory_power1.xlsx' | # factory_demand_file_name = 'factory_power1.xlsx' | ||||||
|  | factory_demand_file_name = 'factory_power1.csv' | ||||||
| electricity_price_data = 'electricity_price_data.csv' | electricity_price_data = 'electricity_price_data.csv' | ||||||
| electricity_price_data_sell = 'electricity_price_data_sell.csv' | electricity_price_data_sell = 'electricity_price_data_sell.csv' | ||||||
|  |  | ||||||
| pv_df = pd.read_csv(pv_yield_file_name, index_col='Time', usecols=['Time', 'PV yield[kW/kWp]']) | pv_df = pd.read_csv(pv_yield_file_name, index_col='Time', usecols=['Time', 'PV yield[kW/kWp]']) | ||||||
| pv_df.index = pd.to_datetime(pv_df.index) | pv_df.index = pd.to_datetime(pv_df.index) | ||||||
|  |  | ||||||
| start_date = '2023-01-01' | df_power = pd.read_csv('factory_power1.csv', index_col='Time', usecols=['Time', 'FactoryPower']) | ||||||
| df_power = pd.read_excel(factory_demand_file_name,  | df_power.index = pd.to_datetime(df_power.index) | ||||||
|                          header=None,  |  | ||||||
|                          names=['FactoryPower'],  |  | ||||||
|                          dtype={'FactoryPower': float}) |  | ||||||
| times = pd.date_range(start=start_date, periods=len(df_power), freq='15min') |  | ||||||
| df_power['Time'] = times |  | ||||||
| df_power.set_index('Time',inplace=True) |  | ||||||
| print(df_power.head()) |  | ||||||
|  |  | ||||||
| df_combined = pv_df.join(df_power) | df_combined = pv_df.join(df_power) | ||||||
|  |  | ||||||
|      |  | ||||||
|  |  | ||||||
| price_df = pd.read_csv(electricity_price_data, index_col='Time', usecols=['Time', 'ElectricityBuy']) | price_df = pd.read_csv(electricity_price_data, index_col='Time', usecols=['Time', 'ElectricityBuy']) | ||||||
| price_df.index = pd.to_datetime(price_df.index) | price_df.index = pd.to_datetime(price_df.index) | ||||||
| price_df = price_df.reindex(df_combined.index) | price_df = price_df.reindex(df_combined.index) | ||||||
|  |  | ||||||
| print("Electricity price data generated and saved.") |  | ||||||
| df_combined2 = df_combined.join(price_df) | df_combined2 = df_combined.join(price_df) | ||||||
|  |  | ||||||
| sell_df = pd.read_csv(electricity_price_data_sell, index_col='Time', usecols=['Time', 'ElectricitySell']) | sell_df = pd.read_csv(electricity_price_data_sell, index_col='Time', usecols=['Time', 'ElectricitySell']) | ||||||
| sell_df.index = pd.to_datetime(sell_df.index) | sell_df.index = pd.to_datetime(sell_df.index) | ||||||
| sell_df = sell_df.reindex(df_combined.index) | sell_df = sell_df.reindex(df_combined.index) | ||||||
|  |  | ||||||
| df_combined3 = df_combined2.join(sell_df) | df_combined3 = df_combined2.join(sell_df) | ||||||
|  |  | ||||||
| with open('combined_data.csv', 'w', newline='') as file: | with open('combined_data.csv', 'w', newline='') as file: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user