def debug(msg):
import sys
frame = sys._getframe(1)
name = frame.f_code.co_name
line_number = frame.f_lineno
filename = frame.f_code.co_filename
return 'File "%s", line %d, in %s: %s' % (filename, line_number, name, msg)
print(debug('hehe'))
File "/home/sergey/Рабочий стол/Projects/l.py", line 12, in <module>: hehe
import pandas as pd
src = [
{'category': 'software', 'name': 'irssi', 'version': 5},
{'category': 'software', 'name': 'irssi', 'version': 4},
{'category': 'software', 'name': 'hexchat', 'version': 2},
{'category': 'software', 'name': 'hexchat', 'version': 3},
{'category': 'software', 'name': 'hexchat1', 'version': 1}
]
dst = (
pd.DataFrame(src)
.sort_values('version')
.drop_duplicates(['category', 'name'])
.to_dict('records')
)
import numpy as np
lst = [[1, 2], [3, 4], [5, 6]]
# Способ 1
list(map(sum, zip(*lst)))
# Способ 2
np.array(lst).sum(axis=0)