-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5bac61
commit 9310070
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
import pandas as pd | ||
from huggingface_hub import HfFileSystem | ||
|
||
fs = HfFileSystem() | ||
|
||
|
||
def get_pv_metadata(testset: pd.DataFrame): | ||
|
||
# download from hugginface or load from cache | ||
cache_dir = "data/pv" | ||
metadata_file = f"{cache_dir}/metadata.csv" | ||
if not os.path.exists(metadata_file): | ||
os.makedirs(cache_dir, exist_ok=True) | ||
fs.get("datasets/openclimatefix/uk_pv/metadata.csv", metadata_file) | ||
|
||
# Load in the dataset | ||
metadata_df = pd.read_csv(metadata_file) | ||
|
||
# join metadata with testset | ||
metadata_df = metadata_df.rename(columns={"ss_id": "pv_id"}) | ||
combined_data = testset.merge(metadata_df, on="pv_id", how="left") | ||
|
||
# only keep the columns we need | ||
combined_data = combined_data[ | ||
["pv_id", "datetime", "latitude_rounded", "longitude_rounded", "kwp"] | ||
] | ||
|
||
# rename latitude_rounded to latitude and longitude_rounded to longitude | ||
combined_data = combined_data.rename( | ||
columns={ | ||
"latitude_rounded": "latitude", | ||
"longitude_rounded": "longitude", | ||
"kwp": "capacity", | ||
} | ||
) | ||
|
||
return combined_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters