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
-2
votes
2 answers

finding special elements in an array

I have such an array: x = np.array([[1,2], [3,4], [5,6]]) I want to find elements bigger than 3. I am trying: ppoc = np.zeros((3,3)) ixu = np.argwhere(x > 2) ppoc = ppoc[0, ixu] But the problem is ppoc is a 2*2 array, but I…
user15788706
-2
votes
1 answer

return all indices of first elements in a list where subsequent values increase incrementally

Need to find indices very similar to here But I have a list of multiple groups of incrementing values, e.g. lst = [0,1,2,7,8,9] Expected output: [0,3]
Hud
  • 301
  • 1
  • 12
-2
votes
1 answer

Numpy array operation to shift index

I have a very specific situation: I have a long 1-D numpy array (arr). I am interested in those elements that are greater than a no. (n). So I am using: idx = np.argwhere(arr > n) and: val = arr[idx] to get the elements and their indices. Now the…
Peedaruos
  • 39
  • 5
-2
votes
1 answer

How do I create, from a tuple of fractions, a new tuple with their decimal values?

I have a tuple of fractions: data = (-17/7, 5/14, -11/14) I want an additional tuple with their decimal equivalents: (-2.43, 0.36, -0.79) This will work: print((round(float(data[0]),2), round(float(data[1]),2), round(float(data[2]),2))) but…
-2
votes
1 answer

Three-Star Programmers Anonymous

My name is Bob and I am a three-star programmer. Well, more accurately, I'm trying not to be. I have read a lot on the internet and this site about how "three-star programmer" is a Very Bad Thing. And I can see why. I have read very little (very…
bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
-2
votes
1 answer

Indexing words in a file according to their line with AWK

Suppose I have a file similar to the following: hello hello hi hi hello hey I would like to find the indices of every unique line and using a comma as the indices separator. So ideally, the output would be like: hello 1,2,5 hi 3,4 hey 6 What has…
hsuh01
  • 13
  • 2
-2
votes
2 answers

Identifying a substring in Python (moving along indices within a string) - can only concatenate str (not "int") to str

I'm new to Python and coding and stuck at comparing a substring to another string. I've got: string sq and pattern STR. Goal: I'm trying to count the max number of STR pattern appearing in that string in a row. This is part of the code: STR = key …
Sabie
  • 77
  • 1
  • 8
-2
votes
1 answer

Is it advisable to add additional Indices to MySQL tables when using CakePHP

I've written a POS and back office system, and now after 18 months of customer use I'm looking to improve performance specifically with reporting. The code is written using CakePHP version 2. I can't find any reference to using additional database…
Robin Walmsley
  • 85
  • 1
  • 1
  • 10
-2
votes
1 answer

Python 3.6: List indices must be integers or slices, not tuples

I am new to Python and trying to make a fill in the blanks quiz. I have researched the error in different forums and still can't manage to correct my code. I feel that I should be able to do this but I just can't see the answer. The error is in def…
10nry
  • 17
  • 2
  • 3
-2
votes
2 answers

How to fix the TypeError (list indices must be integers, not str) in this program?

In one of the program I am using, I am getting a TypeError when trying to mine/parse a value out of dict type data. Below is a brief part of that python program: for c in results: print('value of c : ', c, type(c)) # what I added to see the…
everestial007
  • 6,665
  • 7
  • 32
  • 72
-2
votes
1 answer

List indices must be integers or slices, not str - Python

I'm using a dictionary to compile data about stocks and such but when I come to reference the gtin code input by the user, i get the error 'List indices must be integers or slices, not str - Python' This is the only section of code that causes…
AntsOfTheSky
  • 195
  • 2
  • 3
  • 17
-2
votes
3 answers

Python: Call array value for calculation (int to float)

I crawled the web but no answer (specific to solution). I got stuck with the following: coin = [2.0 , 1.0 , 0.5, 0.1, 0.05, 0.02, 0.01] kum=0.0 for i in coin : while True : if kum + coin[i] >= x : # Intial (first loop) this should be equal to:…
Josi Dunk
  • 51
  • 4
-2
votes
1 answer

Max values of every 5 items in Python?

have a list of 20 items. I want to create a new list than only contain the max value of every five items. Here is was I have: listA = [1,2,23,4,5,6,7,40,9,10,100,12,13,14,15,700,17,18,19,20] for i in len(range(listA): print i How can I create…
airzinger1
  • 151
  • 9
-2
votes
3 answers

List indices must be integers, not str , What are indices? How do I iterate the string?

I am in need of some help. I don't know why the type error, list indices must be integers, not str, comes up. I'm trying to take the first character of isbn and multiply it by 10, and the second by 9, and so on. And after that has finished I need to…
Tosh
  • 25
  • 7
-2
votes
3 answers

Is there a way to generate a list of indices using numpy

Can I use numpy to generate repeating patterns of indices for example. 0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10, 0, 11, 12, 13, 14, 15 or 0,1,2,1,2,3,4,5,6,5,6,7 Is there a method in numpy i can use to generate these lists between a range…
Oly
  • 370
  • 5
  • 16
1 2 3
58
59