-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grouping considering existing and non existing indices #12
Comments
1: define sorted. I suppose you mean sorting by the values in each split group; but what does that mean when splitting a multidimensional array in the first place? Ill add that as a rule of thumb, you really want to avoid using split; or using jagged arrays in numpy generally. Unless the downstream processing steps truly demand this format, it is usually more elegant and always more performant, to find a way to do your operations on the array as a whole. And its almost always possible! |
so as you see my values are sorted per group but not as elements of the list. For sorting it as list I need to do and extra step with a
so the question was whether I could avoid this extra step
Imagine that I have
Then I am creating a matrix
Then I have and the corresponding
Now what I want to do, is to group the values in The way I am doing it at the moment is the following: First I am finding the missing indices from
Then I am labeling the missing indices in
Then reshaping to the size of unique rows in
and finally applying the row-wise binning and mapping:
the idea behind this procedure above was whether I could simplify some parts with Apologies for the long post. |
Sorry; I gave it 10 minutes but I cannot figure out what it is you intend to achieve. Conceptually, what does the matrix m represent? |
the binning result of matrix |
Hi guys, I am trying to use your library for my project but I am stuck.
I have a couple of numpy arrays:
and
idxs = [ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21]
tri = [731, 703, 703, 731, 731, 731, 731, 693, 673, 699, 689, 731, 727, 731, 731, 731, 731, 731, 730]
Initially I wanted to group the values in
idxs
,tri
andpnts
based on the values ofidxs
which are indices to rows oforig
so that they correspond to the same value per row inorig
. For example I would like to get:idxs = [[0,1], [2,3], [4,5], [7], [8,9], [10,11], [12,13], [14,15], [17], [18], [20,21]]
tri = [[731, 703], [703, 731], [731, 731], [731], [693, 673], [699, 689], [731, 727], [731, 731], [731], [731], [731, 730]]
and
Also imagine that at the end I would have to apply the same on corresponding matrices with quite a few million inputs. In any case I was able to group my output by applying the following:
However, I have two questions
eq.split()
without to need to apply an extra step?eq.split()
will group the data based on the existing indices given byidxs
, however if in case that I did not have an index inidxs
(the corresponding values intri
andpnts
will also be missing) for one of the rows inorig
how I could put an empty list in the corresponding position so that I keep the dimension of my output arrays to the size each unique row in myorig
array?e.g. if 17 was not in my initial
idxs
array my output array should be: [[0, 1], [2, 3], [4, 5], [7], [8, 9], [10, 11], [12, 13], [14, 15], [], [18], [20, 21]]in practice I could get the non existing indices by:
but I am not sure whether this would help somehow.
The text was updated successfully, but these errors were encountered: