indices

Python index selection in a 3D list

Python index selection in a 3D list Question: I have the following 3D list: test = [[[(x,y,z) for x in range(0,5)] for y in range(5,8)] for z in range(0,4)] test[0].append([(0,5),(5,0)]) I want to select all the indices of the first dimension, the 0th index of the 2nd dimension and all the indices of the 3rd …

Total answers: 1

Stacking column indices on top of one another using Pandas

Stacking column indices on top of one another using Pandas Question: I’m looking to stack the indices of some columns on top of one another, this is what I currently have: Buy Buy Currency Sell Sell Currency Date 2013-12-31 100 CAD 100 USD 2014-01-02 200 USD 200 CAD 2014-01-03 300 CAD 300 USD 2014-01-06 400 …

Total answers: 3

find local maxima and their indices in a python list

find local maxima and their indices in a python list Question: I have a large data set and I am trying to find the local maxima and their indices. I have made it to get the local maxima but can’t find a way to get their indices. The thing is that I need the maxima …

Total answers: 1

Is there a way to handle negative indices without if statements?

Is there a way to handle negative indices without if statements? Question: Python handles negative indices so that they subtract from the length. For example, if we have this list xs = [1,2,3,4], doing xs[-1] would give us 4, the last element, which would be the same as xs[len(xs)-1]. Now, an easy way to handle …

Total answers: 1

finding all the indices of with a value in a list of lists

finding all the indices of with a value in a list of lists Question: I am trying to find all the indices that have the same values in a list. but in my list, there are lists inside the list and I don’t know how to do it I found how to do that for …

Total answers: 1

How to increment index in Python loop

How to increment index in Python loop Question: I am wanting to loop through a string and capture 2 items each time while also incrementing through the index of the iterable. So I want to slice 2 items but increase the index by 1 every time through the loop. How can I do this? my_string …

Total answers: 7

What is the order of evaluation in python when using pop(), list[-1] and +=?

What is the order of evaluation in python when using pop(), list[-1] and +=? Question: a = [1, 2, 3] a[-1] += a.pop() This results in [1, 6]. a = [1, 2, 3] a[0] += a.pop() This results in [4, 2]. What order of evaluation gives these two results? Asked By: graffe || Source Answers: …

Total answers: 5

TypeError: list indices must be integers or slices, not list

TypeError: list indices must be integers or slices, not list Question: array = some kind of list with 3 columns and unlimited amount of rows with data inside of it. Volume = array[0][2] counter = 0 for i in array: if Volume == array[i][2]: #<—— why is this line a problem? counter += 1 Asked …

Total answers: 2