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?
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...
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...
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...
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...
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],...
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]...
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...
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 ...
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 = [...
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...
Ricketts asked 13/6, 2021 at 9:13
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 ...
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: ...
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 ...
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
>...
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
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...
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...
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...
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...
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
1 Next >
© 2022 - 2024 — McMap. All rights reserved.