-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Description
In the Elexon forecast data processing pipeline, assignment to start_time is performed on a DataFrame slice, which raises a pandas SettingWithCopyWarning.
This warning occurs when a transformation is applied to a view rather than a standalone DataFrame, which may lead to unpredictable behavior.
Expected Behavior
- No
SettingWithCopyWarningshould be emitted during Elexon preprocessing tests. - Column assignments should operate on a safe DataFrame copy or use
.loc.
Actual Behavior
SettingWithCopyWarningis raised when assigning tostart_time.
Scope
elexon_plots.pyonly.
Suggested Fix
Avoid chained assignment by explicitly creating a copy of the DataFrame or using .loc before mutating columns.
Example approaches:
df = df.copy()
df["start_time"] = ...or
df.loc[:, "start_time"] = ...Validation
Run the following test to confirm the warning is resolved:
python -m pytest tests/test_elexon_plot.py -qVerify:
- Tests pass successfully
SettingWithCopyWarningno longer appears
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels