Issue
I have a pandas dataFrame like this.
The X, Y, Z are they (x,y,z) coordinates that represent a point inside a cube of side-length 255.
I want to create a numpy array/dataFrame from this, whose index will be the (x,y,z) coordinates and value is the intensity.
the output should be
data[133,55,250] = 8
data[133,61,254] = 21
...
I tried something like this
data = np.zeros((255,255,255), dtype=np.int)
index = np.array((temp['X'], temp['Y'], temp['Z']))
but returned index is a (3,15) array.
I want a index where
data[index] = intensity
will give me my result.
Solution
Instead of
index = np.array((temp['X'], temp['Y'], temp['Z']))
you could use integer array indexing to perform the assignment:
data = np.zeros((256, 256, 256), dtype=np.int)
data[temp['X'], temp['Y'], temp['Z']] = temp['intensity']
Answered By - unutbu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.