Tagged Questions
1
vote
1answer
38 views
uniform sampling from a ellipsoidal confidence region
I have a 4-dimensional ellipsoid from which I want to draw samples uniformly. I thought of an approach using a hyper cube around the ellipsoid. We can draw a sample from it and check if it is in the ...
0
votes
1answer
39 views
Add value 1 in an multidimension array in python [closed]
I have a multidimension numpy array in python created like this:
>>> import numpy as np
>>> a = np.zeros((3,5))
>>> print a
>>>[[ 0. 0. 0. 0. 0.]
[ 0. 0. ...
1
vote
3answers
38 views
Python array([]) function
I tried printing a variable in a python code that I have and I got this:
[array([ 1., 0.]), array([ 0., 1.]), array([ 0., 1.]), array([ 1., 0.])]
What does this code snippet mean?
1
vote
1answer
31 views
Python 3.3 IndexError doesn't make sense
I have a multidimensional array in py3.3, looks like
[ # big container
[ # month container
['date string', 'temp'],['date string', 'temp'] #dates in month
], #close month container
[ # ...
1
vote
2answers
37 views
How to insert a list as a column in a 2D-list?
Given a list and a 2d-list (that may or may not be the same length)
list1 = [1,2,3,4]
list2 = [1,2]
table = [[1,2,0],
[3,4,1],
[4,4,4]]
I want to append the list as a column to ...
2
votes
2answers
22 views
How to create a sub-matrix in numpy
I have a two-dimensional NxM numpy array:
a = np.ndarray((N,M), dtype=np.float32)
I would like to make a sub-matrix with a selected number of columns and matrices. For each dimension I have as ...
-1
votes
2answers
43 views
Accessing elements of [[[i j k l]]]
I've recently started working with Python and image processing. The HoughLinesP function from CV outputted this "[[[465 391 521 391]]]" and I need to export the values to an excel sheet afterwards. ...
1
vote
1answer
34 views
3D volume acrobatics in python.. selecting x/y/z rows/columns in 3D numpy arrays
I'm new to ndarrays in Numpy, so please be kind.
I have a 3D raw volume imported into numpy as a dtype uint8 array with shape
(309L, 138L, 134L) representing Z, Y, X dimensions.
The Raw image ...
1
vote
0answers
15 views
Skimage simple imread of image return strange output
I'm using the image reading of skimage module, and can't understand the output i get.
I'm trying to read a simple rgb image "lena.png" in the following way :
from skimage import io
im = ...
-4
votes
0answers
30 views
Changing values in multidimensional array
Hi i am writing a method for changing neighbour values in multidimensional array. Method has to change up down left and right neighbours' values if it on sides of array it change otherside value. For ...
2
votes
2answers
28 views
recursively traverse multidimensional dictionary and export to csv
I've have a complex multidimensional dictionary that I want to export some of the the key value pairs to a csv file as a running log file. I've tried the various help with exporting to cvs functions ...
-3
votes
6answers
85 views
I have a [ [ [3,4,5,6] ] ] , how to transform it to [3,4,5,6] in python? [duplicate]
I have a multi-dimensional list [ [ [ 3,4,5,6 ] ] ] . how do I transform it into a single dimensional list [3,4,5,6] in python ?
0
votes
1answer
55 views
How to do numpy structural arrays
I'm having trouble getting my head around structural arrays in numpy.
lets say i have
two lists of tuples (to use native python types). foo_list and bar_list.
len(foo_list)==len(bar_list) The ...
4
votes
1answer
74 views
numpy multidimensional indexing and diagonal symmetries
I have a pretty large numpy array ...
power = ...
print power.shape
>>> (3, 10, 10, 19, 75, 10, 10)
which is symmetric w.r.t. the 10x10 parts, i.e the following 2-d matrices are symmetric
...
2
votes
1answer
35 views
Cummulative matrix multiplication on successive square arrays in an (M,M,N) or similar array?
Say I have N MxM arrays in a single MxMxN array. Is there any simple way in numpy to do a cummulative matrix multiplication of successive MxM arrays (the MxMxN array can be overwritten). I can do it ...
1
vote
0answers
64 views
Python: Create a multidimensional array from a loop
Please can you help, I am struggling how to create a multidimensional array from a loop.
I am looping through rows in a data table and want to pass these to an array.
Thanks
Jay
from ...
0
votes
1answer
25 views
Multidimensional lists and their dependency
I have a question about removing the dependency in multidimensional lists in python.
Currently I have a (simplified) code snippet out of my bigger script:
mylist = [ 1,2,3 ]
listreplaced = mylist
...
0
votes
2answers
46 views
python: how to determine if multidimensional array is empy, and value error
I'm initializing an array like this:
import numpy as np
g = np.array([no_classes, no_features, no_classes])
no_classes and no_features are both integers, let's say they equal 2 and 3 respectively. ...
2
votes
2answers
54 views
putting numpy ndarray data into pandas
I want to put the following data into pandas for further analysis.
import numpy as np
import pandas as pd
from pandas import DataFrame
data = np.array([[[1, 1, 1, np.nan, 1], [np.nan, 1, 1, 1, 1]],
...
1
vote
1answer
82 views
Correlation coefficient of multidimensional arrays
I want to compute the correlation between the two arrays a and b; the shape of a and b is (10, 2). I expect a correlation matrix with shape (10, 10) with values in the range [-1, 1]; a correlation ...
0
votes
1answer
29 views
Get a value from multidimensional, with variable number of dimensions, dictionary in python [duplicate]
I have a multidimensional dictionary. List of dimensions is given as a variable. How do I use all the dimensions in that list and access the value stored at the end.
def get_value(dict, dimensions):
...
2
votes
1answer
49 views
Python: Normalize multidimensional array
I have code to generate and export 12 stereo WAVs
Currently I'm just doing:
for i in range(0,12):
filename = "out_%d.wav" % i
L = ... some list of floats between -1.0 and +1.0 ...
R = ...
0
votes
5answers
52 views
Parsing CSV to 2 dimensions array
I have a samples.csv files and this archive has this structure:
354,174,27c,20,5c,287,382,a3
59,359,152,115,19d,15a,143,113
8f,1e6,291,55,b1,3f9,39b,ba
3cf,77,20c,316,164,e2,2cb,3c9
...
0
votes
0answers
9 views
how to plot a multi-variables function
i have a function of 3 variables f(v,m,t) and i do a interpolation with python.How can i plot f(v,t) for m=constant ? like a 2d function with imshow() by example, wish doesn't work here of course.
...
3
votes
1answer
59 views
Trying to rearrange two dimensional list into a different two dimensional list
Given an input of something like:
"Date 3" "Location A" "some data"
"Date 3" "Location B" "some data"
"Date 3" "Location C" "some data"
"Date 2" "Location A" "some data"
"Date 2" "Location B" ...
1
vote
1answer
59 views
plotting 3d vectors (arrays) in python
Using numpy Packet i produced vectors (arrays) contain x,y,z-coordinates of several atoms in a protein. I would like to plot these vectors.
Does anybody know how to do this?
Since I could't plot the ...
1
vote
3answers
29 views
Convert multidimensional array dimension in Python
Is it possible to convert this:
[ [0], [1], [2], [3], [4], [5], [[6,9]], [7], [8], [[6,9]] ]
into this:
[ [0], [1], [2], [3], [4], [5], [6,9], [7], [8], [6,9] ]
5
votes
5answers
53 views
How to substract multidimensional array in Python?
I have this multidimensional array:
n = [[1], [2], [3], [4], [5], [6], [7, 10], [8], [9], [7, 10]]
I want to substract all of them with 1. So the result will be:
result = [[0], [1], [2], [3], [4], ...
1
vote
1answer
34 views
combine multidementional array into key based dictionary object
I am trying to create a price schema for a product, basing on its color, size and material.
My current way of implementation is to maintain 1 JSON object which contains all the options and trying to ...
0
votes
1answer
73 views
Forming numpy array from array buffer from shared memory (multiprocessing) fails
I need to have a multidimensional array in a shared memory between two processes. I'm trying to make a simple example that works: I send [1, 2, 3, 4, 5, 6, 7, 8, 9] to the other process, which ...
0
votes
3answers
18 views
Using the reduce function on a multidimensional array
So i have a particular array, that has 2 seperate arrays withing itself. What I am looking to do is to average together those 2 seperate arrays, so for instance, if i have my original array such as ...
2
votes
3answers
104 views
Selecting specific rows and columns from NumPy array
I've been going crazy trying to figure out what stupid thing I'm doing wrong here.
I'm using NumPy, and I have specific row indices and specific column indices that I want to select from. Here's the ...
1
vote
2answers
33 views
Multi-dimensional ndarray set operations
I have the need to run the set difference of two potentially large multidimensional numpy.ndarrays.
My tests have proven unsuccessful trying to extend the numpy.setdiff1d to work for multidimensional ...
0
votes
0answers
25 views
python 3d list not exceeding [duplicate]
I've created a 3d list in python
size = 10
game = [[[random.randint(0, 1) for _ in range(size)] for _ in range(size)]for _ in range(size)]
then i try to iterate over this list
for x in ...
1
vote
2answers
61 views
Python: Iterating on the lines and columns of an array
I am looking for a simple and efficient way to iterate on an matrix (2D array) by lines and columns. Using Python.
I have 3 2D-matrices of the same size: one containing x-coordinates, one for ...
1
vote
2answers
57 views
get “1” for a one-dimensional numpy.array using a shape-like function
In a function, I give a Numpy array : It can be multi-dimentional but also one-dimentional
So when I give a multi-dimentional array :
np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]).shape
>>> ...
1
vote
3answers
51 views
How do I concatenate an array into a 3D matrix?
In my Python application I have a 3D matrix (array) such this:
array([[[ 1., 2., 3.]], [[ 4., 5., 6.]], [[ 7., 8., 9.]]])
and I would like to add, in a particular "line", for example, in the ...
0
votes
0answers
114 views
Multiprocessing : NULL result without error in PyObject_Call
Here is a sample program where I use multiprocessing. The calculations are done with multiprocessing.Process and the results are collected using multiprocessing.Queue.
#THIS PROGRAM RUNS WITH ~40Gb ...
4
votes
2answers
58 views
Sort order of lists in multidimensional array in Python
I would like to turn this data in Python (sorted alphabetically):
test = [['ma', 'e', 'wa', 'ka'], ['ma', 'haa', 'laa'], ['ma', 'ka', 'm', 'haa', 'laa', 'ca', 'j', 'ra'], ['ma', 'ra'], 'ma']
Into a ...
3
votes
2answers
85 views
Use Numpy Multidimensional Array Slicing Without Using the [slice,slice] Syntax?
Is there are a way to use Numpy's multidimensional array slicing without using the [slice, slice] syntax?
I need to be able to use it from normal function calls, but I haven't found a way to use the ...
1
vote
2answers
137 views
Numpy Polyfit or any fitting to X and Y multidimensional arrays
I have two large multidimensional arrays: Y carries three measurements of half a million objects (e.g. shape=(500000,3)) and X has same shape, but contains position of Y measurements.
At first, I ...
1
vote
2answers
134 views
Apply functions to 3D numpy array
I have a numpy 3D array from Image(PIL/Pillow) object.
[[178 214 235]
[180 215 236]
[180 215 235]
...,
[146 173 194]
[145 172 193]
[146 173 194]]
...,
[[126 171 203]
[125 169 203]
...
3
votes
3answers
189 views
Python list set value at index if index does not exist
Is there a way, lib, or something in python that I can set value in list at an index that does not exist?
Something like runtime index creation at list:
l = []
l[3] = 'foo'
# [None, None, None, ...
2
votes
1answer
49 views
multiple condition in fancy indexing
I am new to python and am trying to some simple classification on raster image.
Basically, I am reading a TIF image as a 2D array and do some calculating and manipulation on it. For classification ...
3
votes
1answer
42 views
Multidimensional arrays, using range, while simultaneously having a set start, stop, and step?
Oy mates,
I am learning numpy on my own and getting a pretty good handle on it, a few concepts elude me even after reading the documentation though. I am trying to go through this matrix and make ...
0
votes
1answer
46 views
Profile time series in pandas?
I discovered pandas a short while ago, and it seems very interesting. Until now I'm usually using structured masked arrays in Python, and it seems pandas can offer an alternative, in particular since ...
0
votes
2answers
53 views
Multidimensional Array sets multiple rows/columns
So I am having a strange problem in python. I am using the code below to create a plot of places where the object has been. Here is my code:
def GoForward(self, duration):
if (self.TowardsX - ...
1
vote
2answers
98 views
Python multiprocessing memory management for a loop over multidimensional array
Here is the sample program for multiprocessing using python. I see the memory usage by each process is ~2 to 3 times higher than the memory each process is supposed to use. If I calculate with just ...
10
votes
4answers
357 views
Difference between numpy.array shape (R, 1) and (R,)
In numpy, some of the operations return in shape (R, 1) but some return (R,). This will make matrix multiplication more tedious since explicit reshape is required. For example, given a matrix M, if we ...
0
votes
2answers
40 views
Multidimensional slicing in raw Python
Let's say I have an array defined as
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
and I wanted to get a vertical slice, returning [2, 5, 8]. Is there any way to do this with slicing syntax in ...