How to pass index in python for loop
list = [a,b,c,d] for i, val in enumerate(list): print(i, val)
list = [a,b,c,d] for i, val in enumerate(list): print(i, val)
combs = [] list1 = [1,2,3] list2 = [3,1,4] for x in list1: for y in list2: if x != y: combs.append((x, y)) print(combs) print(combs[2][0]) print(combs[2][1]) results in: [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)] 2 3 But there’s also a more elegant solution using list comprehensions: list1 … Read more
Also, imagine we have list that we need to disassemble a list and split it into 4 different lists like these: [1, 5, 9] [2, 6, 10] [3, 7, 11] [4, 8, 12] Then we should do the following params = [0.25, 0.5, 0.75, 1] a_list = [1, 2, 3, 4, 5, 6, 7, 8, … Read more
I found a great cheat-sheet image that shows how Numpy slicing works: Thanks to scipy-lectures.org
When getting this error, instead of dff[“New Time”] = dff[“Old Time”].strftime(“%d/%m/%Y %H:%M”) we should add “.dt” (it can be used to access the values of the series as datetimelike and return several properties.) dff[“New Time”] = dff[“Old Time”].dt.strftime(“%d/%m/%Y %H:%M”)