0
votes
1answer
10 views

Brand new to scipy/numpy and attempting some batch manipulation

So, I have a bunch of scanned images with annoying white around them that I want to remove. I'm prepping an algorithm using numpy arrays to find the closest pixel row and columns of complete white, ...
3
votes
2answers
31 views

numpy column arrays and strange results

I am trying to write a function where its arguments are arrays with different shapes. I am having some troubles to understand column arrays and to make my function work for all shapes of arrays, here ...
2
votes
1answer
27 views

Numpy: Rearrange array based upon index array

I'm looking for a one line solution that would help me do the following. Suppose I have array = np.array([10, 20, 30, 40, 50]) I'd like to rearrange it based upon an input ordering. If there were ...
0
votes
1answer
21 views

How do I convert Python POST data to JSON?

I have the following code in Python: def post(self): example = self.request.get("example") other = self.request.get("other") How do I get all post data if unknown? I'm very new to Python ...
0
votes
1answer
11 views

Generate random string from wxListBox in Pythong

My code below allows the user to enter a customer name (string) into a wxTextCtrl field and then click a button to add the customer's name to a wxListBox. if not self.addCustText.IsEmpty(): ...
1
vote
0answers
33 views

How to broadcast a numpy 2D-array to a 6D-array

I have three six-dimensional Numpy arrays (running on python 3.4) of form Weights MyValue WeightedValue = Weight * MyValue I would like to determine the weighted average of MyValue weighted by ...
0
votes
0answers
39 views

Find all possible groupings of adjacent elements in a 2d array

I have a 2d array, say 1 2 3 4 5 6 7 8 9 0 a b c d e f I am trying to break this array into four groups of 4, where each group contains adjacent items. One example of this might be [1, 2, 3, 4], ...
2
votes
1answer
51 views

Python: Optimize deletion of elements not aligned in a numpy array

I'm working with very big matrices using numpy 1.6.2 and python 2.7. Given an N x M matrix A and a map B where I can find, for each row, the index of the element to delete. Here is an example: A = ...
0
votes
1answer
38 views

fit along one dimension of numpy array

I have a numpy array (sums_norm) of dimension (44,36) and I would like to fit all its rows with a known function. (This question is an extension of the already asked curve fitting with a known ...
3
votes
4answers
61 views

Convert structured array with various numeric data types to regular array

Suppose I have a NumPy structured array with various numeric datatypes. As a basic example, my_data = np.array( [(17, 182.1), (19, 175.6)], dtype='i2,f4') How can I cast this into a regular ...
0
votes
2answers
23 views

Create a vector with values from a Numpy array selected according to criteria in a Pandas DataFrame

I am working with a pandas df that contains two columns with integers. For each data of the df, I would like to select these two integers, use them as [row,column] pairs to extract values from a ...
0
votes
1answer
31 views

numpy won't work in IDLE

I'm running python 2.7.3 on window 8. I'm writing some code that requires me to use the numpy.add() function. I downloaded numpy 1.6.0 for win32 py 2.7 from sourceforge. I have no idea how to "build" ...
0
votes
1answer
37 views

numpy efficient array multiplication

I have a three dimensional array img of shape [1200,1600,3] and a two dimensional array labels of shape [1200,1600]. The first array is from an image, the second one is from labels in the image. ...
0
votes
2answers
65 views

Iterate through all possible values in array which give 1 in sum

I have an array of 4 values. For example: [0.1, 0.1, 0.5, 0.3] (sum of elements = 1) How to iterate though all possible values with increment 0.1 to get in sum 1. example: [1.0, 0.0, 0.0, 0,0] [0.9, ...
0
votes
3answers
33 views

Remove Keys in Dictionary and Store Values in a Dictionary of Lists

So I have a dictionary with "items" which has a list of dictionaries. I'm trying to restructure it to be a dictionary of "items" that has a list of lists that contain the values of the previous ...
2
votes
1answer
32 views

Data structure for NumPy indexed array [on hold]

I have a 2D NumPy array (N, D) where each row has a unique index (a non-negative integer). The indices of the rows are increasing. For example, the indices of my (4,D) array could be (10, 20, 21, 30). ...
0
votes
0answers
33 views

How to insert big array to the mysql with python?

I have around 5000000 strings in array and I need to write each as a row to the mysql db, as fast as I can. Now I'm using multiprocessing: def my_api_off(api): print api db = ...
0
votes
2answers
27 views

T-Test on between groups of numpy arrays

I have two groups of numpy arrays (A,B) and I want compare both groups using a statistical t-test (Two sample t-test). The result should again be an array of the same dimensions providing e.g. the ...
1
vote
1answer
21 views

numpy select submatrix according to index

I want to select a submatrix according to some columns index and rows index. I get a strange error. I am able to slice the matrix according to the rows index of to the columns index but not ...
1
vote
1answer
14 views

Partial derivative of a function with numpy.array input

I have a function like: def fun(A, B, C): return numpy.sum(numpy.dot(A, B)) + numpy.sum(C) Where A, B, C are 2-dimensional numpy.array, and the return value is a float value How can I get the ...
-2
votes
3answers
26 views

How can I make a list of a input string the user has typed into Python?

I'm new in programming and in my script I have to create a list with a input string y the user. I know how basic of slicing works and making a list ex: list = [] but I need to write the code so ...
0
votes
1answer
20 views

array form : excel sheet data to python in numpy array form [duplicate]

I need your help to transfer data to array form shape. I know how to import excel sheet to python using this Data = pd.read_excel('filename.xls',sheetname='1',header=None) But when this Data in ...
1
vote
2answers
43 views

List comprehension-like approach for numpy arrays with more than one dimension

I have a list of 2d numpy arrays of the same height but not width: list_of_arrays = [np.random.rand(3,4),np.random.rand(3,5),np.random.rand(3,6)] I want to build a new array where each column is a ...
0
votes
1answer
24 views

Creating Multidimensional arrays and interpolating in Python

I have 8 arrays, when each one is plotted it gives 'x Vs. Detection Probability'. I want to combine these arrays so that I can perform a multidimensional interpolation to find the detection ...
1
vote
3answers
28 views

Convert elements within an array into floats in python

Hi I am quite new to python and what I want to do is simple but I just can't seem to get around it. I have a simple array as shown below: A1 = [('1.000000', '4.000000'), ('2.000000', '5.000000'), ...
2
votes
1answer
31 views

Find non crossing pairs in Array and remove iteratively in python until no pairs are left

I have a list of tuples containing start and end index point of each pair in an array. (2,72), (20,73),(22,70), (25,30) I want to extract a pair say A such that no other pair in the array has a ...
1
vote
1answer
38 views

Interpolation giving different results for almost identical arrays

I'm trying to interpolate two 2-dimensional arrays. The original array is shown in blue in the image below. The second one shown, in red, is the same array in blue but moved up and slightly to the ...
4
votes
2answers
41 views

Instantiate a matrix with x zeros and the rest ones

I would like to be able to quickly instantiate a matrix where the first few (variable number of) cells in a row are 0, and the rest are ones. Imagine we want a 3x4 matrix. I have instantiated the ...
-1
votes
2answers
28 views

Getting the maximum of one column of a list of arrays

If I have an ordered dictionary of numpy arrays from collections import OrderedDict >>> bias OrderedDict([('bias_0.0', array([[ -4.76624398e-04, 4.49229230e-03, 1.70000000e+01], ...
0
votes
0answers
28 views

Converting a numpy array to a c array in Python using SWIG [duplicate]

I tried to interface a C code as a shared object to Python using SWIG as a part of a bigger project. The trouble I am having is when tried to pass buffers between them. I was unsuccessful and I could ...
0
votes
0answers
24 views

FloatingPointError: overflow encountered in double_scalars

I've set up numpy.seterr as follows: np.seterr(invalid='raise', over ='raise', under='raise') And I'm getting the following error: c = beta[j,i] + oneminusbeta[j,i] FloatingPointError: ...
-1
votes
2answers
40 views

Python - XY array from 2 lists

I've 2 lists : x = [1, 2, 3, 4, ...] y = [11, 12, 13, 14, ...] And I would like to obtain an array like this : XY = [ [1,11] , [2,12], ... [xN,yN] ] To create a plot like this: How to draw line ...
-2
votes
1answer
28 views

Loop searching all possible combinations in an array

I'm having trouble with an algorithm in python. I have an array of 4 values [a,b,c,d] those are percentages so at any given time a+b+c+d=1. I need a loop that goes through all possible combinations of ...
3
votes
1answer
67 views

Can we have a faster way of creating an array?

Is there a faster way to create the following array? I need to create an array for further calculation. This array creation is taking lot of time to run. Basically I need to create a Series or an ...
1
vote
1answer
35 views

Single operation to take the matrix product along only the last two dimensions

This is probably obvious on reflection, but it's not clear to me right now. For a pair of numpy arrays of shapes (K, N, M) and (K, M, N) denoted by a and b respectively, is there a way to compute the ...
1
vote
1answer
25 views

Sort a 1D array and a 2D array(by column) simultaneously

I have two arrays, a 1D array called Amplitudes with shape (99,) and a 2D array called Modes with a shape (55714,99). I want to sort these two arrays such that, the columns of the Modes array arranges ...
4
votes
2answers
76 views

In-place shuffling of multidimensional arrays

I am trying to implement a NaN-safe shuffling procedure in Cython that can shuffle along several axis of a multidimensional matrix of arbitrary dimension. In the simple case of a 1D matrix, one can ...
-4
votes
0answers
32 views

python code: for all leaf nodes in an xml file, find all of their parents [closed]

Assume we have an xml file. What I want is to put in a two dimensional array/list(using python) all the parents of each leaf node, with the order of the parents intact. Each row of the 2D array would ...
1
vote
0answers
63 views

Numpy memory management

I'm trying to apply the numpy palette method following this tutorial: http://opencvpython.blogspot.it/2012/06/fast-array-manipulation-in-numpy.html But I got a wrong image using the following code: ...
0
votes
2answers
38 views

Manipulation with arrays in numpy

After long work with R I returned to work with Python and find that array maniputation is not very convenient. Arrays cannot be indexed by row and column names. I hope that someone can help and show ...
1
vote
2answers
38 views

Adding column to numpy array based on where condition

I have a numpy array and I would like to update a column of values in it with data from a second array. Somewhat like a vlookup function in excel. Need to look-up the first column of a in the b ...
1
vote
2answers
64 views

Fit a line to a matrix in python

I have a matrix of shape 256x256 to which I'm trying to find a line of best fit. This is an image by the way, so these are simply intensity values. Let's assume I want to find the line of best fit ...
0
votes
1answer
23 views

Creating variables in loop for dynamicly creating griddata()

I am trying to write a function for a numerical algorithm. The funciton should take in number of dimensions and upper and lower bounds for some state variables. Then, I would like the function to ...
0
votes
1answer
26 views

Pandas - convert columns to grouped array coordinates

I have a DataFrame of (x, y) coordinates that I would like to transform into array's to perform pairwise distance calculations on. df = pd.DataFrame({'type': ['a', 'a', 'a', 'b', 'b', 'c', 'c', ...
-7
votes
2answers
60 views

Python:Find array sum [closed]

This task is actually quite hard for me. My task is to find out the highest happiness Sarah can achieve given her bag capacity and items available for sale. Sarah carries a bag that can carry at most ...
-1
votes
1answer
41 views

Why is the total sum of the list incorrect?

I am solving project Euler's exercise 1: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all ...
0
votes
2answers
31 views

Python Pandas: selecting element in array column

I have the following data frame: pa=pd.DataFrame({'a':np.array([[1.,4.],[2.],[3.,4.,5.]])}) I want to select the column 'a' and then only a particular element (i.e. first: 1., 2., 3.) What do I ...
1
vote
1answer
14 views

resolution issues with my ipython map (matplotlib)

Ive been working with python, Im quite new with all this language. ive been trying to make a list become and array and then to give me on each row the highest value. Now this information comes from a ...
1
vote
1answer
66 views

How does `numpy.einsum` work?

The correct way of writing a summation in terms of Einstein summation is a puzzle to me, so I want to try it in my code. I have succeeded in a few cases but mostly with trial and error. Now there is ...
0
votes
1answer
41 views

Alphabet to integers

I'm trying to create a programm in which a user inputs a string e.g 'roller' and the program converts the alphabet to numbers such as a=1, b=2, c=3 etc, and the calculate the sum of these values. But, ...