You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

bw2calc 1.8.2中LCA.to_dataframe无法导出LCI数据的问题咨询

bw2calc 1.8.2 导出LCI数据的替代方法

问题背景

此前使用bw2calc旧版本时,可通过LCA.to_dataframe(matrix_label="inventory", cutoff=None)导出LCI数据,但升级到1.8.2版本后执行代码报错:

LCA.to_dataframe() got an unexpected keyword argument 'matrix_label'

原报错代码:

import bw2calc as bc
import bw2data as bd

print(bc.__version__)
eidb = bd.Database("ecoinvent 3.5 cutoff")

# 随机选取活动
random_act = eidb.random()
funct_unit = {random_act:1}

# 初始化LCA并计算
lca = bc.LCA(funct_unit, ('IPCC 2021', 'climate change', 'global warming potential (GWP100)'))
lca.lci()
lca.lcia()
# 报错行
lca.to_dataframe(matrix_label = "inventory", cutoff = None)

解决方案

bw2calc 1.8.x版本对数据导出方法做了拆分,不再通过matrix_label参数指定矩阵类型,而是提供了专门的导出方法:

  • 使用lci_to_dataframe()直接导出LCI库存数据,保留cutoff参数支持
  • 对应影响评价结果可使用lcia_to_dataframe()导出

修改后的代码:

import bw2calc as bc
import bw2data as bd

print(bc.__version__)
eidb = bd.Database("ecoinvent 3.5 cutoff")

random_act = eidb.random()
funct_unit = {random_act:1}

lca = bc.LCA(funct_unit, ('IPCC 2021', 'climate change', 'global warming potential (GWP100)'))
lca.lci()
lca.lcia()

# 导出LCI数据,支持cutoff过滤
lci_df = lca.lci_to_dataframe(cutoff=None)

这个方法的功能与旧版to_dataframe(matrix_label="inventory")完全一致,无需自行手动转换lca.inventory矩阵。

内容的提问来源于stack exchange,提问作者Hannah Wang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 21:05:08