-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_hourly.py
More file actions
27 lines (21 loc) · 931 Bytes
/
merge_hourly.py
File metadata and controls
27 lines (21 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
# Load your dataset
# Assuming your dataset is in a CSV file named 'data.csv'
data = pd.read_csv('./Data/City of Boulder Electric Vehicle Charging Station Energy Consumption/merged_dataset.csv')
# Convert the 'Time' column to datetime
data['Time'] = pd.to_datetime(data['Time'])
# Set the 'Time' column as the index
data.set_index('Time', inplace=True)
# Group by hour and aggregate
hourly_data = data.resample('H').agg({
'Total Occupied': 'max',
'tempmax': 'mean', # Modify aggregation as needed
'tempmin': 'mean', # Modify aggregation as needed
'temp': 'mean', # Modify aggregation as needed
'precip': 'mean', # Example for sum
'precipprob': 'mean', # Example for mean
"snow": "mean",
"snowdepth": "mean"
})
print(hourly_data)
hourly_data.to_csv('./Data/City of Boulder Electric Vehicle Charging Station Energy Consumption/merged_dataset_hourly.csv', index=True)