我在其他线程上尝试了多种不同的建议,但似乎没有任何效果(是的,我对lol编程是新手)。你知道吗
我有以下代码:
SysLength = defaultdict(list) #empty dictionary
for x in SystemDict:
length = len(SystemDict[x]) #obtains length of each system
SysLength[x].append(length) #adds system and length to the dictionary
SysMin = sorted(SysLength, key=SysLength.get) #sorts systems from smallest to largest
emailDict = defaultdict(list) #empty dictionary
for x in SysMin: #cycles through lowest system first
for email in SystemDicto3[x]: #cycles through email in the lowest system
emailDict[email] = 0 #adds email to dictionary and sets it equal to 0
for x in SysMin:
for email in SystemDicto3[x]:
if emailDict[email] < 3: #if count is below 3, pass email through
emailDict[email] += 1 #adds 1 to each email passed through
SystemDictu4[x].append(email)
我对这句话有意见:
SystemDictu4[x].append(email)
我要做的是在键值“x”后面加上“email”。SystemDictu4是一个defaultdict,每个键下有1000个条目,我需要将email变量添加到这些键中。你知道吗
我得到以下错误:
TypeError: cannot concatenate a non-NDFrame object
显示的代码是正确的,但正如@jpp所建议的那样,我回顾了SystemDictu4字典是如何创建的。我最初创建字典的方法是使用以下代码片段:
经过一些测试,我了解到在最后一行的末尾添加
.values.tolist()
(在['Email']之后),它可以工作,不会变成一个序列。谢谢大家的帮助!你知道吗相关问题 更多 >
编程相关推荐