indices Questions

20

Solved

index() will give the first occurrence of an item in a list. Is there a neat trick which returns all indices in a list for an element?
Attribute asked 9/6, 2011 at 14:12

6

Solved

I have a 2 dimensional NumPy array. I know how to get the maximum values over axes: >>> a = array([[1,2,3],[4,3,1]]) >>> amax(a,axis=0) array([4, 3, 3]) How can I get the indices...
Glazing asked 29/3, 2011 at 7:35

6

Solved

How can I find a character in a String and print the position of character all over the string? For example, I want to find positions of 'o' in this string : "you are awesome honey" and get the ans...
Godgiven asked 11/10, 2013 at 9:2

4

Supose we have a matrix like this one: # Set seed set.seed(12345) # Generate data.frame df <- matrix(sample(1:100,100), nrow = 10) I would like to get the row and column where the first n hi...
Li asked 30/5, 2023 at 6:40

6

Solved

Assume to have a torch tensor, for example of the following shape: x = torch.rand(20, 1, 120, 120) What I would like now, is to get the indices of the maximum values of each 120x120 matrix. To s...
Haymes asked 8/11, 2018 at 16:53

4

Solved

For two lists a and b, how can I get the indices of values that appear in both? For example, a = [1, 2, 3, 4, 5] b = [9, 7, 6, 5, 1, 0] return_indices_of_a(a, b) would return [0,4], with (a[0],...
Fasciate asked 28/4, 2012 at 19:53

3

Solved

I need to generate lower triangle matrix indices (row and columns pairs). The current implementation is inefficient (memory wise) specially when symmetric matrix gets big (more than 50K rows). Is t...
Trammel asked 3/1, 2014 at 7:24

4

Solved

I want to split a string by a list of indices, where the split segments begin with one index and end before the next one. Example: s = 'long string that I want to split up' indices = [0,5,12,17]...
Implacental asked 1/6, 2012 at 13:43

4

I have 3 vectors: x <- c(3, 5, 2) y <- c(3, 2, 1, 1, 2, 3, 4, 5, 4, 5) z <- c(2, 4, 8, 1, 5) x is the number of elements in each group. y gives indices to extract elements from z. The fir...
Rufous asked 15/7, 2022 at 10:19

3

Solved

I want to do something like this. Let's say we have a tensor A. A = [[1,0],[0,4]] And I want to get nonzero values and their indices from it. Nonzero values: [1,4] Nonzero indices: [[0,0],[1...
Norahnorbert asked 30/8, 2016 at 5:34

7

Solved

Given the following vector, a = [1, 2, 3, 4, 5, 6, 7, 8, 9] I need to identify the indices of "a" whose elements are >= than 4, like this: idx = [3, 4, 5, 6, 7, 8] The info in "idx" will b...
Irredentist asked 5/12, 2012 at 6:21

3

Solved

I'm slightly confused with index range operator: I expected that the expression myString[..0] should be equvalent to myString[0..0], then myString.Substring(0, 1) or myString[0].ToString(), and in ...
Delphina asked 26/2, 2022 at 17:18

5

Solved

I have the following problem. Having a list of integers, I want to split it, into a list of lists, whenever the step between two elements of the original input list is not 1. For example: input = [...
Pyretic asked 22/2, 2013 at 8:34

1

Solved

I am doing a binary classification. May I know how to extract the real indexes of the misclassified or classified instances of the training data frame while doing K fold cross-validation? I found n...

6

Solved

I have a tbl_df where I want to group_by(u, v) for each distinct integer combination observed with (u, v). EDIT: this was subsequently resolved by adding the (now-deprecated) group_indices() back ...
Bellabelladonna asked 12/4, 2014 at 4:38

1

Solved

I'm a Windows C# developer, new to iOS/SwiftUI development and I think I've worked myself into a hole here. I have a view with a @Binding variable: struct DetailView: View { @Binding var project: ...
Spectrometer asked 2/2, 2021 at 21:14

2

The task seems to be simple, but I cannot figure out how to do it. So what I have are two tensors: an indices tensor indices with shape (2, 5, 2), where the last dimensions corresponds to indices ...
Ism asked 20/1, 2021 at 18:42

6

Solved

I'd like to do arithmetics with k-th diagonal of a numpy.array. I need those indices. For example, something like: >>> a = numpy.eye(2) >>> a[numpy.diag_indices(a, k=-1)] = 5 &gt...
Hoiden asked 7/6, 2012 at 4:29

4

How would one find the minimum value in each row, and also the index of the minimum value? octave:1> a = [1 2 3; 9 8 7; 5 4 6] a = 1 2 3 9 8 7 5 4 6
Winded asked 10/8, 2017 at 8:29

3

Solved

I've read documentation several times about np.indices() but I can't seem to grasp what is it about. I've used it numerous times on things to see what it does, but I still can't really get it. May...
Pons asked 28/8, 2015 at 12:41

1

Solved

my problem is: I have simple array with some Items. I want to display a List with these items using a ForEach with .indices(). (This is because my actual problem handles with Toggle in a List and f...
Wow asked 15/7, 2020 at 7:23

1

Solved

In legacy code I found an index as follows: CREATE CLUSTERED INDEX ix_MyTable_foo ON MyTable ( id ASC, name ASC ) If I understand correctly, this index would be useful for querying on column i...
Legra asked 8/5, 2020 at 13:11

12

Solved

Is there a way to get the list index name in my lapply() function? n = names(mylist) lapply(mylist, function(list.elem) { cat("What is the name of this list element?\n" }) I asked before if it's...
Scofield asked 30/3, 2012 at 20:40

3

Solved

How to perform a sum just for a list of indices over numpy array, e.g., if I have an array a = [1,2,3,4] and a list of indices to sum, indices = [0, 2] and I want a fast operation to give me the an...
Gaffe asked 9/12, 2017 at 23:39

4

Solved

My code below is giving me the following error "IndexError: too many indices for array". I am quite new to machine learning so I do not have any idea about how to solve this. Any kind of help would...
Stamin asked 31/10, 2016 at 11:44

© 2022 - 2024 — McMap. All rights reserved.