Questions tagged [numpy]

1 votes
1 replies
How to generate a 3D grid of vectors ? (each position in the 3D grid is a vector)
I want to generate a four dimensional array with dimensions (dim,N,N,N). The first component ndim =3 and N corresponds to the grid length. How ca...
asked 1 month ago
0 votes
1 replies
Slope of a regression line using numpy/pandas
I'm trying to write a piece of code that given two lists of numbers, finds the beta coefficient. This can be done by finding the slope of the lin...
asked 1 month ago
0 votes
1 replies
Create NonUniformImage based on Numpy 2d array with custom cell width and height
I'm trying to make a "heatmap" with Matplotlib of a 2d Numpy Array and found the NonUniformImage option here. Below is a simple single version. U...
asked 1 month ago
1 votes
1 replies
Python: Shuffle and put back into initial order elements of an numpy array
I have an array on which I must modify some values. In order to do so, I have to change the order of elements of the array, after having changed...
asked 1 month ago
1 votes
1 replies
Function doesn't work anymore if run by more than one time in Python 3.7
I'm dealing with some simulations in Python and I have the following code: import numpy as np import matplotlib.pyplot as plt from statsmodels.s...
1 votes
1 replies
Replace duplicate set of values with NaN
If I had the following data: +---------------+---------------------+---------------------+----------+--------------+ | email | date_open...
asked 1 month ago
-2 votes
0 replies
Python Dataframe: Combining columns and settling values into different columns
I am setting up a table which should settle down mapping of MAC against same user and discard the last one if exceeds the allowed limit. Followi...
asked 1 month ago
0 votes
1 replies
Python 2.7 - saving a 1D array and a 2D array on the same csv
I have a 1D array of sgape (4) as follow: ['rsmin_025_lai_chtessel' 'rsmin_050_lai_chtessel' 'rsmin_075_lai_chtessel' 'rsmin_100_lai_chtess...
asked 1 month ago
-2 votes
1 replies
Why can't I use numpy library in processing.py?
My problem is that i can't import numpy into my processing.py project. When I try to import it i get the error "No module named numpy". What ca...
asked 1 month ago
-1 votes
2 replies
Converting coef function of R in Python
I have R script which calculates the Intercept according to the code mentioned below library(zoo) data = matrix(rexp(200), 10) X <- data[,3]...
asked 1 month ago
0 votes
1 replies
np.save is converting floats to weird characters
I am attempting to append results to an ongoing csv file. Each result comes out as an nd.array: [IN]: Print(savearray) [OUT]: [[ 0.55219001 0....
asked 1 month ago
0 votes
1 replies
How to transform 3rd dimension of Numpy array loaded with ImageIO
I have a numpy array of shape (128,128,3) loaded from a PNG using ImageIO. Dimension 3 seems to represent RGB values. In this instance all value...
asked 1 month ago
0 votes
4 replies
Interpolation Python
My problem is quite a simple one, however I can't seem to find a quick solution. I would like to interpolate the y_model array which is defined...
asked 1 month ago
-1 votes
0 replies
Is there a better way to compute mean of data inside 2D dimensional numpy object in pandas series without iterating over all the rows?
I have created a pandas series that holds 2D numpy array. Numpy array in each row is of different shape. 0 [[15, 131, 232], [62, 150, 250...
asked 1 month ago
-1 votes
0 replies
Is there a way for numpy to directly match multiple position data in the matrix?
matrix A matrix (a matrix of red lines) is known to find all occurrences in another matrix. As shown, in a multidimensional array, I need to matc...
asked 1 month ago
0 votes
2 replies
How do I append a column of ints to a 2D matrix of floats in numpy?
I have a row of ints that I would like to add as a column to a 2D matrix of floats. So when combined, the first column would be the column of int...
asked 1 month ago
0 votes
1 replies
Python, NumPy: Neural network tutorial, ValueError: shapes not aligned
I'm trying to code a neural network with 3 input nodes, a hidden layer with 4 nodes, and 1 output node. (This will change in the final version, s...
1 votes
1 replies
Why does Matlab interp1 produce different results than numpy interp?
EDIT: Code edited to produce results consistent with Matlab. See below. I am converting Matlab scripts to Python and the linear interpolation re...
asked 1 month ago
2 votes
3 replies
Consecutive events below threshold
I have SPI timeseries of length 324 and values ranging from -3 to +3. I want to get the indices of places where 3 or more consecutive timesteps a...
asked 1 month ago
0 votes
0 replies
Create column and set value where multiple other column conditions are met
New to using pandas and need to convert some SAS code. Trying to create a column and set a value if multiple other column conditions are met. H...
asked 1 month ago
0 votes
1 replies
How to create an array of neighbors out from each element in an numpy 2d array
I am trying to create an array of neighbors for each element in an array. Is there a way to use vectorisation techniques to speed it up? I've us...
asked 1 month ago
0 votes
1 replies
Numpy.where evaluating as True when condition is False
I'm currently experiencing some unexpected behaviour in numpy. I am trying to add a column to a DataFrame which does some math on two other colum...
asked 1 month ago
2 votes
0 replies
Python 3 - ValueError: Found array with 0 sample(s) (shape=(0, 11)) while a minimum of 1 is required by MinMaxScaler
I'm really having trouble trying to get this project of mine up and running, but I'm remaining resilient and I think I'm close! I'm trying to c...
3 votes
1 replies
Is there a faster way to get the Local Binary Pattern of the MNIST dataset?
I need to know if there's a faster way to get the LBP and the resulting histograms of the MNIST dataset. This will be used for handwritten text r...
1 votes
0 replies
Pandas: Filter Column by how many times the item shows up in a DataFrame [duplicate]
So I have a pandas DataFrame that looks like this: r vals positions 1.2 1 1.8 2 2.3 1 1.8 1 2.1 3 2.0 3 1...
asked 1 month ago