Update app.py
Browse files
app.py
CHANGED
@@ -12,21 +12,23 @@ from plotting import (
|
|
12 |
)
|
13 |
|
14 |
def load_data_in_chunks(file_path, selected_columns, start_date=None, end_date=None, chunksize=10000):
|
15 |
-
# Load the entire header
|
16 |
header = pd.read_csv(file_path, nrows=0, header=[0, 1, 2])
|
17 |
|
18 |
-
# Filter the required columns
|
19 |
columns = [col for col in header.columns if col[2] in selected_columns]
|
20 |
-
columns = [('datetime', '', '')] + columns
|
21 |
|
22 |
chunks = []
|
23 |
-
for chunk in pd.read_csv(file_path, chunksize=chunksize,
|
24 |
-
#
|
25 |
chunk.columns = header.columns
|
|
|
|
|
26 |
chunk = chunk[columns]
|
27 |
|
|
|
28 |
if start_date and end_date:
|
29 |
-
chunk = chunk[(chunk
|
30 |
|
31 |
chunks.append(chunk)
|
32 |
|
@@ -60,12 +62,6 @@ heatmap_temperature = pn.widgets.Checkbox(
|
|
60 |
# Create a loading spinner
|
61 |
loading_spinner = pn.indicators.LoadingSpinner(width=50, height=50)
|
62 |
|
63 |
-
# Panel interactive functions
|
64 |
-
@pn.depends(
|
65 |
-
inverter_ids.param.value,
|
66 |
-
plot_power_curves.param.value,
|
67 |
-
plot_temperature_curves.param.value,
|
68 |
-
)
|
69 |
@pn.depends(
|
70 |
inverter_ids.param.value,
|
71 |
plot_power_curves.param.value,
|
|
|
12 |
)
|
13 |
|
14 |
def load_data_in_chunks(file_path, selected_columns, start_date=None, end_date=None, chunksize=10000):
|
15 |
+
# Load the entire header to get multi-level column names
|
16 |
header = pd.read_csv(file_path, nrows=0, header=[0, 1, 2])
|
17 |
|
18 |
+
# Filter the required columns including datetime
|
19 |
columns = [col for col in header.columns if col[2] in selected_columns]
|
|
|
20 |
|
21 |
chunks = []
|
22 |
+
for chunk in pd.read_csv(file_path, chunksize=chunksize, header=[0, 1, 2], index_col=0, parse_dates=True):
|
23 |
+
# Assign multi-level columns
|
24 |
chunk.columns = header.columns
|
25 |
+
|
26 |
+
# Filter the necessary columns
|
27 |
chunk = chunk[columns]
|
28 |
|
29 |
+
# Apply date range filtering if necessary
|
30 |
if start_date and end_date:
|
31 |
+
chunk = chunk[(chunk.index >= start_date) & (chunk.index <= end_date)]
|
32 |
|
33 |
chunks.append(chunk)
|
34 |
|
|
|
62 |
# Create a loading spinner
|
63 |
loading_spinner = pn.indicators.LoadingSpinner(width=50, height=50)
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
@pn.depends(
|
66 |
inverter_ids.param.value,
|
67 |
plot_power_curves.param.value,
|