我正在尝试创建一个包含 18330 行的数据框字典。但字典停在第 15275 行。我无法理解相同的根本原因。
'''
final_dict = dict()
item = df1['Item Code']
id = df1['store ID']
sp = df1['Selling Price']
mrp = df1['MRP']
for a in range(0, item.__len__()):
key = str(item[a]) + "|" + str(id[a])
value = str(sp[a]) + "|" + str(mrp[a])
final_dict[key] = value
key_list = final_dict.keys()
print(item.__len__())
print(len(final_dict))
print(len(key_list))
print(len(df1.index))
df1['key'] = key_list
print(df1)
'''
Output:
18330
15275
15275
18330
error : "ValueError: Length of values does not match length of index"
数据框示例:
谁能帮我理解我的错误。
猛跑小猪
相关分类