目录:
1. 嵌套列表对应位置元素相加 (add the corresponding elements of nested list)
2. 多个列表对应位置相加(add the corresponding elements of several lists)
3. 列表中嵌套元组对应位置相加 (python sum corresponding position in list neseted tuple)
4. 判断列表中所有元素是否都是0 (python check if all element in list is zero)
5. 寻找列表中所有最大值的位置 (python find all position of maximum value in list)
6. 计算列表中出现次数最多的所有项 (python get all value with the highest occurrence in list)
7. 生成等间隔列表 (python create list in same space)
8. 寻找嵌套列表的最大值 (python find max value in nested list)
9. 找到列表中的众数 (python find mode in list)
10. 列表按照某个规则排序 (python sort a list according to an regulation)
11. 列表里面元素所有是否满足某一个条件 (python check if all element of a list matches a condition)
12. 对两个列表一起进行排序 (python sort two list in same order)
13. 把嵌套的列表平铺成一个列表 (python convert nested list to a flat list)
内容:
1. 嵌套列表对应位置元素相加 (add the corresponding elements of nested list)
方法1:
>>> lis=[[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7]]
>>> [sum(x) for x in zip(*lis)]
[6, 9, 12, 15, 18]
方法2:
>>> seq = np.array([
... [1,2,3,4,5],
... [2,3,4,5,6],
... [3,4,5,6,7]])
>>> np.sum(seq,axi