问题描述
| Job Number | Contact |
|:-----------|------------:|
| 1234 | SR |
| | JF |
| 5678 | PK |
| | JF |
| 8910 | LT |
| | SR |
我希望这样重组:
SR:1234,7891
JF:5678,1234
LT:7891
我已经写了这个(可耻的)代码:
contactsLst = list(projects['Contact'])
contactsstr = ' '.join(list(projects['Contact']))
emails = FindEmails(contactsstr)
uniqueEmails = [x for i,x in enumerate(emails) if i == emails.index(x)]
mask = np.zeros((len(uniqueEmails),len(contactsLst)),dtype=bool)
i = -1
j = -1
for email in uniqueEmails:
i += 1
j = -1
for contact in contactsLst:
j += 1
if contact == email or email in contact:
mask[i,j] = True
else:
mask[i,j] = False
print(mask)
jobsOn = []
i = -1
for email in uniqueEmails:
i += 1
jobsOn.append(str(list(projects['Job Number'][mask[i,:]])).strip('[]'))
return uniqueEmails,jobsOn
它只是这样做,但是它比整个项目的其余部分更长...有没有更简单的方法?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)