PyPSA / pypsa-usa

PyPSA-USA: An Open-Source Energy System Optimization Model for the United States
https://pypsa-usa.readthedocs.io
MIT License
58 stars 23 forks source link

In the function `format_eia_api_data`, many datasets are missing US-level data (e.g. ng_industrial_price) thus will cause an error in the lambda function #235

Closed casinocullen closed 7 months ago

casinocullen commented 7 months ago

Checklist

The Issue

Potential solution is to add if bool(usa_average) else df["value"] in the end of apply

    df["value"] = df.apply(
        lambda x: x["value"] if not x["use_average"] else usa_average[x["period"]], 
        axis=1,
    ) if bool(usa_average) else df["value"]

Steps To Reproduce

No response

Expected Behavior

No response

Error Message

No response

Anything else?

No response

trevorb1 commented 7 months ago

Good call, @casinocullen! This is addressed with the eia.py module, and any missing data is replaced with USA average. This function should probably be removed. Relates to Issue #231!