我从网络上删除了数据帧,这些数据帧的功能来自用户输入的数据。然而,我的一些包含汽车特征的专栏文章对相同的特征有不同的大小写,例如:“加热座椅”和“加热座椅”。这些都是虚拟变量,因此带有加热座椅的汽车一列的值为0,另一列的值为1。最终目标是添加所有具有相同功能的列,只是大小写不同。有没有人知道有什么库可以帮助循环遍历数百个特征来检查像这样大小写不匹配的对?
谢谢
发布于 2018-01-06 15:25:02
让我们以python dict格式的两列为例。例如:
python_dict = {'Heated Seats':0, 'heated seats':1}
sum = 0
reference_string = 'HEATED SEATS' #Take the reference string here just to compare. In your case no need to take.
for key in python_dict.keys():
if key.lower() == reference_string.lower():
#Adding the values of Heated seats car values
sum = sum + python_dict[key]
print sumhttps://stackoverflow.com/questions/48124970
复制相似问题