the values of energy consumption , seem a bit low compared to what i got, may i have a brief description of the model you used
here is how i resampled and grouped the data respectively
#Loading the Data
houses = pd.read_excel(‘electricity_house-summary.xlsx’)
apartments = pd.read_excel(‘electricity_apartment-summary.xlsx’)
Preprocessing the Data to handle missing data
houses[‘timestamp’] = pd.to_datetime(houses[‘timestamp’], utc=True)
apartments[‘timestamp’] = pd.to_datetime(apartments[‘timestamp’], utc=True)
houses.fillna(method=‘ffill’, inplace=True)
apartments.fillna(method=‘ffill’, inplace=True)
Setting timestamp as index for resampling
houses.set_index(‘timestamp’, inplace=True)
apartments.set_index(‘timestamp’, inplace=True)
#Analyzing Energy Consumption Patterns
Resampling data to hourly intervals since its given in 30 mins intervals ikn the original dataset
houses_hourly = houses.resample(‘H’).mean()
apartments_hourly = apartments.resample(‘H’).mean()
Visualizing resampled energy consumption
plt.figure(figsize=(10, 5))
plt.plot(houses_hourly.index, houses_hourly[‘Mean’], label=‘Houses’)
plt.plot(apartments_hourly.index, apartments_hourly[‘Mean’], label=‘Apartments’)
plt.xlabel(‘Time’)
plt.ylabel(‘Energy Consumption (kWh)’)
plt.title(‘Hourly Energy Consumption: Electricity Heating’)
plt.legend()
plt.show()
#Grouping the data by hour and calculating the average energy consumption per hour
houses_hourly_avg = houses_hourly.groupby(‘hour’)[‘Mean’].mean()
apartments_hourly_avg = apartments_hourly.groupby(‘hour’)[‘Mean’].mean()
Plotting average hourly consumption
houses_hourly_avg.plot(label=‘Houses’, legend=True)
apartments_hourly_avg.plot(label=‘Apartments’, legend=True)
plt.title(‘Average Hourly Energy Consumption’)
plt.xlabel(‘Hour of Day’)
plt.ylabel(‘Energy Consumption (kWh)’)
plt.show()