how to merge two lists and get names of lists with the highest value for each index?

Advertisements I am trying to compare two lists of odds from two bookmakers. They look like this: List1 = [‘2.66’, ‘3.79’, ‘1.88’, ‘1.61’, ‘2.51’, ‘1.29’, ‘2.29’, ‘2.56’, ‘3.16’, ‘2.05’, ‘2.95’, ‘2.64’, ‘2.26’, ‘3.17’, ‘2.64’, ‘2.25’] List2 = [‘2.70’, ‘4.40’, ‘1.87’, ‘1.56’, ‘2.50’, ‘1.26’, ‘2.33’, ‘2.60’, ‘3.20’, ‘2.04’, ‘3.00’, ‘2.65’, ‘2.25’, ‘3.20’, ‘2.65’, ‘2.22’] I need… Read More how to merge two lists and get names of lists with the highest value for each index?

Why numpy.vectorize calls vectorized function more times than elements in the vector?

Advertisements When we call vectorized function for some vector, for some reason it is called twice for the first vector element. What is the reason, and can we get rid of this strange effect (e.g. when this function needs to have some side effect, e.g. counts some sum etc) Example: import numpy @numpy.vectorize def test(x):… Read More Why numpy.vectorize calls vectorized function more times than elements in the vector?

Elementwise insertion of array into array using numpy

Advertisements Let’s say I have an array of years created like years = np.arange(2024,2051,1) And I have an array of months created like months = np.arange(1,13,1) What is the most pythonic way of arriving at an elementwise concatenation such that the end result is [[2024,1],[2024,2],[2024,3]…[2024,12], [2025,1],[2025,2],[2025,3]…[2025,12], … ] ? Thanks >Solution : I’d say the… Read More Elementwise insertion of array into array using numpy