1
vote
1answer
34 views

numpy applying aggregated information across a 2D array

i have a list of agent's "health" in a 2D array: health=[[0.5,0.8],[0.1,0.5],[0.5,0.7]] and a set of actions( one per agent): actions=[[0,1],[2,0],[1,1]] (possible actions = {0,1,2} depending ...
2
votes
1answer
84 views

Convert 2-d array of strings to float in python_removing scientific notation

How can I convert scientific notations to the original format when I use numpy.astype in x array? Here's my code: with open ('outfile.csv', 'r') as infile: reader = csv.reader(infile) ...
3
votes
1answer
99 views

Can't reshape numpy array

I have a function that is supposed to take a 1D array of integers and shapes it into a 2D array of 1x3 arrays. It then is supposed to take each 1x3 array and shift it into a 3x1 array. The result is ...
0
votes
2answers
63 views

List of 3x1 numpy arrays in Python

I'm trying to write a python function that will take a 1D array of RGB values and make a list of 3x1 arrays that represent pixels. Here is my function def RGBtoLMS(rgbValues, rgbLength): #Passing in ...
0
votes
1answer
661 views

Python Index error (out of bounds) accessing element in 2D array

I'm trying to access an element of a 2d array created from data in a csv file. I can print the array fine. When I try to access the array to find a certain element (i.e. a number from 'row' 1 ...
3
votes
2answers
146 views

iterating over numpy arrays

I am having a very difficult time vectoring, I can't seem to think about math in that way yet. I have this right now: #!/usr/bin/env python import numpy as np import math grid = np.zeros((2,2)) ...
2
votes
1answer
157 views

numpy: 1d histogram based on 2d-pixel euclidean distance from center

I am using python, with scipy, numpy, etc. I want to compute the histogram of intensity values of a grayscale image, based on the distance of the pixels to the center of mass of the image. The ...
2
votes
1answer
157 views

Using a condition to plot with matplotlib

I have a 2-D array and I need to plot columns x and y but only within a certain range of x. I know how to plot using the index but I need to specify the value of x. I have a few of those arrays so I ...
9
votes
4answers
411 views

Sum between pairs of indices in 2d array

Sorry, I do not know the protocol for re-asking a question if it doesn't get an answer. This question was asked a few months ago here: Numpy sum between pairs of indices in 2d array I have a 2-d ...
2
votes
2answers
130 views

How to create a Numpy 2d array with equal difference between rows?

How can I create a (48,64) Numpy array like this: i, i, i, .....,i i+0.1, i+0.1,..........,i+0.1 i+0.2, i+0.2,..........,i+0.2 . . . . i+6.3, i+6.3,..........,i+6.3 0.1 is the fixed ...
1
vote
1answer
378 views

Numpy sum between pairs of indices in 2d array

I have a 2-d numpy array (MxN) and two more 1-d arrays (Mx1) that represent starting and ending indices for each row of the 2-d array that I'd like to sum over. I'm looking for the most efficient way ...
2
votes
3answers
566 views

Manipulating indices to 2d numpy array

I can index a 2d numpy array with a tuple or even a list of tuples a = numpy.array([[1,2],[3,4]]) i = [(0,1),(1,0)] # edit: bad example, should have taken [(0,1),(0,1)] print a[i[0]], a[i] (Gives 2 ...
5
votes
1answer
4k views

numpy - 2d array indexing

According to docs numpy's default behaviour is to index arrays first by rows then by columns: a = numpy.arange(6).reshape(3,2) [[0 1] [2 3] [4 5]] print a[0][1] # is 1 I want to index the array ...