Skip to content
Advertisement

Tag: list

Сonvert list values to dictionary as key and value

Suppose there is a list: [‘1604780184′, ’10’, ‘1604780194’, ‘0’, ‘1604780319’, ’99’, ‘1604780320’, ‘0’] You need to get a result like: {‘1604780184′: ’10’, ‘1604780194’: ‘0’, ‘1604780319’: ’99’, ‘1604780320’: ‘0’} Now I have so: Please advise a better way. Thanks. Answer Most concise (and probably the best) way might be: What it actually does is make use of some pattern your list

Compute cummulative sum until a zero appears

I have a (long) list in which zeros and ones appear at random: list1 = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1] 1.I want to get another list the sum of the list up to where 0 appears where 0 appears, retain 0 in the list list2 = [3, 0, 2, 0, 1, 0, 3]

Occurence of a value in many lists

i have a Series Object in pandas with 2 columns, one for the indices and one with lists, I need to find if a value occurs in only one of these lists and return it with the most optimal way. As an example let’s say we have this i need to return 77 because it occurs in only one of

Advertisement