n.lpf_contingency() returns AttributeError: 'DataFrame' object has no attribute 'to_frame'
维护者通常 2 天内回复
评估
调研方向
traceback 指向 pypsa/network/power_flow.py 第 1003 行附近,位于 lpf_contingency 内部,此处假定 p0_base 是 Series,但实际上它是 DataFrame。请先检查该位置 p0_base 的类型,以及它在函数前面是如何构建的。当复现脚本(ac_dc_meshed()、optimize()、lpf_contingency()、passive_branches_i())运行时不再出现 AttributeError,且现有的潮流计算测试仍然通过,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Version Checks (indicate both or one)
-
I have confirmed this bug exists on the lastest release of PyPSA.
-
I have confirmed this bug exists on the current
masterbranch of PyPSA.
Issue Description
Running n.lpf_contingency() shows the following error:
Traceback (most recent call last):
File "/home/markus/PyPSA/z.py", line 5, in <module>
n.lpf_contingency()
~~~~~~~~~~~~~~~~~^^
File "/home/markus/PyPSA/pypsa/common.py", line 849, in wrapper
return func(self, *args, **kwargs)
File "/home/markus/PyPSA/pypsa/network/power_flow.py", line 1003, in lpf_contingency
p0 = p0_base.to_frame("base")
^^^^^^^^^^^^^^^^
File "/home/markus/PyPSA/.venv/lib/python3.13/site-packages/pandas/core/generic.py", line 6206, in __getattr__
return object.__getattribute__(self, name)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
AttributeError: 'DataFrame' object has no attribute 'to_frame'
Reproducible Example
import pypsa
n = pypsa.examples.ac_dc_meshed()
n.optimize()
n.lpf_contingency()
n.passive_branches_i()
Expected Behavior
No error message.
Installed Versions
- 主要语言
- Python
- 星标
- 2.2k
- 派生
- 732
- 平均合并
- 3 天 59 分钟
- 30 天内合并 PR
- 58
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PyPSA/PyPSA 的其他 Issue
-
get_switchable_as_dense ignores order of inds and silently drops unknown names可能已有人在做 @musaaero 于 7 天前认领。 未关闭breaking components API data validation
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
-
gap optimization
难度 5/5 一周以上 新手友好度 25/100
维护者通常 2 天内回复
-
Reserve and adequacy constraints可能已有人在做 @FabianHofmann 于 5 天前认领。 未关闭gap optimization reliability & uncertainty
难度 5/5 一周以上 新手友好度 35/100
PyPSA/PyPSA#2096 · 3 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
AC power flow gap
难度 5/5 一周以上 新手友好度 30/100
维护者通常 2 天内回复
-
Maintenance rows of a fixed modular committable unit have infinite coefficients, and `optimize()` returns status `ok`可能已有人在做 @chenyi6758-source 于 4 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 75/100
维护者通常 2 天内回复
相似的 Issue
-
channels:edit check:passed
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
aws-samples/sample-aws-genai-db-modernizer#2097 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 67/100
ietf-tools/datatracker#12027 ·
维护者通常 1 天内回复
-
[Bug]: Python SDK overwrites OVPack backups with HTTP 200 JSON errors可能已有人在做 @stefanielizeth73-art 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
volcengine/OpenViking#7347 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
deepset-ai/haystack-core-integrations#4228 ·
维护者通常 1 天内回复