Questions tagged [indices]

Use this tag for questions about specifying or selecting the correct information from a structure using indices.

For any set of records, indices are identifiers of which specify information of the address of each record.

Check the Wikipedia page for arrays to know more.

882 questions
-1
votes
1 answer

How to access dictionaries of dictionaries in python

a=[{'1st innings': {'team': 'Islamabad United', 'deliveries': [{0.1: {'non_striker': 'Sharjeel Khan', 'bowler': 'Anwar Ali', 'runs': {'extras': 0, 'total': 0, 'batsman': 0}, 'batsman': 'SR Watson'}}, {0.2: {'non_striker':…
-1
votes
1 answer

Set indices without manually typing them (too many), regular numerical sequences as indices

I have a pandas dataframe with 1111 rows and want to reindex the rows having the following names: First 11 rows: "p000","p100","p200","p300","p400","p500","p600","p700","p800","p900","p1000" Next 100…
Theresa_S
  • 329
  • 1
  • 11
-1
votes
2 answers

Python exercise about finding indices of X in the list

def leesFormulier(l1): index = 0 lres = [] for j in range(len(l1)): for k in range(0,9,2): if l1[j][k] == 'X': lres.append(index+1) index += 1 else: index +=…
george
  • 13
  • 3
-1
votes
2 answers

How can I subtract an index from a list?

I have a really large list of like 3 million elements, say it's x = [1, 2, 3, 4, 5, 6, ..., 3000000] and I have tried subtracting a number from it, like 8, (inputting exactly like this: x - 8) and it thankfully gives me another list of the same…
moeur
  • 9
  • 1
  • 4
-1
votes
3 answers

Getting Error while Iterating over Dictionary in Python

My dictionary is below; I get an error while iterating over it. mk = {'Incident': {'AlertStatus': 'SLA BREACH', 'Area': 'Test', 'Assignee': 'Incident.Coordinator', 'AssignmentGroup': 'Operating System…
Oxxodome
  • 13
  • 4
-1
votes
2 answers

Can I append specific values from one array to another?

I have successfully imported a CSV file into a multi-dimensional array in python. What I want to do now is pick specific values from the array and put them into a new single array. For instance if my current arrays were: [code1, name1, number…
-1
votes
1 answer

Custom OpenGL OBJ model loader indices calculation not working

I followed the tutorial from this website to make a simple model loader. All the coordinates get read well, but one thing it doesn't go over is how to calculate the indices but in one of the further tutorials found here called VBO indexing.…
MrAbnox
  • 23
  • 6
-1
votes
1 answer

Grab the index numbers of a list which have been built by code

I wanted to compare two lists of vector elements and grab the equal elements of the lists and compose a 3rd list, I've already accomplished that.Now, I want to find out what are the index numbers of the elements grabbed from the 1st list.…
AAA Yerus
  • 31
  • 4
-1
votes
1 answer

python type errors in lists

TypeError Traceback (most recent call last) in () ----> 1 df['final_grade'] = 'na' TypeError: list indices must be integers or slices, not str df['final_grade'] = 'na'
-1
votes
1 answer

Find the line number containing a given span

Given a text file, how would one find the line number corresponding to given start and end indices for a substring? Even though the value of any given span can be found, the data set I'm working with contains duplicates.
Steele Farnsworth
  • 863
  • 1
  • 6
  • 15
-1
votes
1 answer

Combination of matrix elements giving non-zero value (PYTHON)

I have to evaluate the following expression, given two quite large matrices A,B and a very complicated function F: The mathematical expression I was thinking if there is an efficient way in order to first find those indices i,j that will give a…
dthed
  • 43
  • 1
  • 6
-1
votes
3 answers

Summing numbers in a list except those between 6 and 7

I'm attempting to write a function which takes a list and sums all the numbers in the list, except it ignores sections of the list starting with a list and extending to a 7, but continues to sum after the 7. Here is my code: def sum67(nums): i =…
-1
votes
2 answers

List Index Out of Range for list[0]

I'm trying to write a simple code which takes a list (nums) and sums the numbers in the list as long as the number isn't 13 or doesn't occur immediately after 13. Here's my code: def sum13(nums): sum = 0 if nums[0] != 13: sum += nums[0] …
-1
votes
2 answers

Deleting rows of repeated labels in Matlab

In Matlab, I have a cell of which the first column is composed of markers of which there are too many. We want to delete the entire row of the cell of these extraneous markers. We have four marker types within the first column of our cell - '71',…
Maheen Siddiqui
  • 539
  • 8
  • 19
-1
votes
1 answer

Assigning values to specific subscript indices in 3D python array throws errors

Say I have initialized an array in 3D as: arr_3d = np.zeros((100, 100, 100)) Now I want to change the elements at subscript indices (i, j, k) of arr_3d to some value (say 1), where i, j, k are the list (or array) of indices with sizes 100, 100, 40,…
user11
  • 191
  • 1
  • 3
  • 11