输入:
word_list = ["a", "b","c","d", "e"]
input1 = [("b",20),("a",10)}
input2 = [("c",9)]
input3 = [("d",70)]
result = merge_blabla(word_list, [input1, input2, input3])
如果每次都可以添加一行,则这一个更好:
^{pr2}$输出如下:
result
>> matrix(array(10,20,0,0,0), array(0,0,9,0,0), array(0,0,0,70,0))
result.colnames
>> ["a", "b", "c", "d", "e"]
实际上,word_list
有1M个元素,结果是一个稀疏矩阵,因此效率可能很重要。在
有人知道如何在python中实现这一点吗?在
使用^{} :
相关问题 更多 >
编程相关推荐