That's a very clever approach. I also found a way using the pandas library
with the groupby function.
points_df = pandas.DataFrame.from_records(buffer)
new_buffer = points_df.groupby(qcut(points_df.index, resolution**3)).mean()
I did the original approach with all of those loops because I need
This wasn't intended to be a histogram, but you're right in that it would be
much better if I can just go through each point once and bin the results,
that makes more sense, thanks!
--
View this message in context:
The points are indeed arbitrarily spaced, and yes I have heard tale of using
spatial indices for this sort of problem, and it looks like that would be
the best bet for me. Thanks for the other suggestions as well!
--
View this message in context:
The idea is that I want to thin a large 2D buffer of x,y,z points to a given
resolution by dividing the data into equal sized "cubes" (i.e. resolution is
number of cubes along each axis) and averaging the points inside each cube
(if any).
*# Fill up buffer data for demonstration purposes
This is the reason I'm doing this in the first place, because I made a pure
python version but it runs really slow for larger data sets, so I'm
basically rewriting the same function but using the Python and Numpy C API,
but if you're saying it won't run any faster then maybe I'm going at it the
I think that I do, since I intend to do array specific operations on the
resulting column of data.
e.g:
*PyArray_Min*
*PyArray_Max*
which require a PyArrayObject argument
I also plan to use *PyArray_Where* to find individual point locations in
data columns x,y,z within a 3D range, but it
Thanks for responding.
It looks you made/found these yourself since I can't find anything like this
in the API. I can't believe it isn't, so convenient!
By the way, from what I understand, the ':' is represented as
*PySlice_New(NULL, NULL, NULL) *in the C API when accessing by index,
correct?
Hello,
is there a C-API function for numpy that can implement Python's
multidimensional indexing?
For example, if I had a 2d array:
PyArrayObject * M;
and an index
int i;
how do I extract the i-th row M[i,:] or i-th column M[:,i]?
Ideally it would be great if it returned another
Cool!
But I'm having trouble implementing this, could you provide an example on
how exactly to do this? I'm not sure how to create the appropriate tuple and
how to use it with PyObject_GetItem given an PyArrayObject, unless I'm
misunderstood.
Much appreciated,
Matthew
--
View this message in