我在github下载了一个源码,里面定义了一个提取放电过程数据的函数getdischarging_values()。这个函数在B5 B6 B7电池数据集上都正常运行,但是提取B18数据集时,报错,KeyError: 'Voltage_measured',拼写错误,但是我检查了,拼写是没有问题的,源码里同时还有一个getcharging_values()的函数,这个函数和前面出问题的函数代码一模一样,只是把charging改成了discharging,但是这个函数在B18数据集就运行正常。新手小白已经搞了一整天了,也没解决,求大神帮忙!
附代码:
定义函数库代码:
import pandas as pd import numpy as np from pandas import DataFrame from pandas import concat from sklearn.model_selection import train_test_split from sklearn.preprocessing import MinMaxScaler
def getChargingValues(Battery, Index): Battery = Battery[Index]['data'] index = [] i = 1 for iterator in Battery['Voltage_measured']: index.append(i) i += 1 return [index, Battery['Voltage_measured'], Battery['Current_measured'], Battery['Temperature_measured'], B