Skip to content

Commit

Permalink
rename columns
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Oct 23, 2024
1 parent 1206ef3 commit d9ffda6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion india_forecast_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def get_generation_data(
# as this is current what ocf_datapipes expects
# This is because we normalize by the watts amount
col = generation_df.columns[0]
generation_df[col] = generation_df[col].astype(float) * 1e3
generation_df[col] = generation_df[col].astype(float) * 1e3\

# rename columns 0 to power_kw
generation_df.rename({col:"power_kw"}, inplace=True)

# Site metadata dataframe
sites_df = pd.DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion india_forecast_app/models/pvnet/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def predict(self, site_id: str, timestamp: dt.datetime):
final_gen_points = 0
final_gen_index = 0
for gen_idx in range(len(generation_da.index.values) - 1, -1, -1):
current_gen = generation_da.isel(index=gen_idx)["0"].values
current_gen = generation_da.isel(index=gen_idx)["power_kw"].values
if not np.isnan(current_gen) and current_gen > 0:
final_gen_points = current_gen * 1000.0
# Convert to KW back from MW
Expand Down
2 changes: 1 addition & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_get_generation_data(db_session, sites, generation_db_values, init_times

# Check for 5 (non-null) generation values
assert len(gen_df) == 5
assert not gen_df["0"].isnull().any() # 0 is the ml_id/system_id of the wind site
assert not gen_df["power_kw"].isnull().any() # 0 is the ml_id/system_id of the wind site

# Check first and last timestamps are correct
assert gen_df.index[0] == init_timestamp - dt.timedelta(hours=1)
Expand Down

0 comments on commit d9ffda6

Please sign in to comment.