我有许多数据帧的字典(df_dict)并通过索引将它们全部连接起来。每个数据帧都有一个或多个相同的列名,当我尝试在 asammdf 中导出信号时,我得到了这个错误:
ValueError: field 'good' occurs more than once
以下是代码:
df_dict 是包含许多数据帧的字典
df_master = pd.concat(df_dict, axis=1)
并在 asammdf 中获取信号,我有以下代码:
for signal in df_master.columns.to_list():
df_master[signal]
test_signal = Signal(samples=df_master[signal], timestamps=timeMaster,
name=signal,
unit='')
sigs.append(test_signal)
mdf.append(sigs)
这是 df_master 列名称:
>> print(df_master.columns.to_list())
>> [('bms', 'bms_id'), ('bms', 'good'), ('bms', 'actualCurrent'), ('bms', 'actualPower'),
('bms', 'actualInternalResistanceCh'), ('bms', 'actualInternalResistanceDisch'), ('bms',
'actualLimitMaxVoltage'), ('bms', 'actualLimitMinVoltage'), ('bms',
'actualMaxChargingCurrent'), ('bms', 'actualMaxChargingPower'), ('bms',
'actualMaxDischargingCurrent'), ('bms', 'actualMaxDischargingPower'), ('bms',
'actualMode'), ('bms', 'actualSoc'), ('bms', 'actualSoh'), ('bms', 'actualSupply'), ('bms',
'actualTemperature'), ('bms', 'actualHighTemperature'), ('bms', 'actualLowTemperature'),
('bms', 'actualVoltage'), ('bms', 'SoC_New'), ('bms', 'Ri'), ('cchamber', 'cchamber_id'),
('cchamber', 'good'), ('cchamber', 'nominalPower'), ('cchamber', 'nominalTemperature'),
('cchamber', 'nominalInternalTemperature'), ('cchamber', 'nominalProcessTemperature'),
('cchamber', 'nominalIncursion'), ('cchamber', 'actualPower'), ('cchamber',
'actualTemperature'), ('cchamber', 'actualLevel'), ('cchamber', 'actualVerror'),
('supplyLoad', 'supplyLoad_id'), ('supplyLoad', 'good'), ('supplyLoad', 'actualCurrent'),
('supplyLoad', 'actualPower'), ('supplyLoad', 'actualSumCurrent'), ('supplyLoad',
'actualSupply'), ('supplyLoad', 'actualVoltage'), ('supplyLoad', 'aliveCounter'),
('supplyLoad', 'chopperState'), ('supplyLoad', 'nominalInnerResistance'), ('supplyLoad',
'nominalSinkCurrent'), ('supplyLoad', 'nominalSinkPower'), ('supplyLoad',
'nominalSourceCurrent'), ('supplyLoad', 'nominalSourcePower'), ('supplyLoad',
'nominalVoltage'), ('supplyLoad', 'switchState')]
我已经尝试将列名更改为 good_bms、actualCurrent_bms、...、good_cchamber 等。但仍然有同样的错误
有人有线索吗?