115,296 questions
Advice
0
votes
10
replies
42
views
python/numpy : generate sound from an inverse fft of a synthetic spectrum
I continue to tinker with some code I found for analysing/categorising sound in .wav files, among others with the amplitude-weighted average and std. deviation of the rfft spectrum (I know, the ...
0
votes
1
answer
147
views
How to eliminate extra dimensions in this 3D Numpy array pattern matching?
This Python script:
import numpy as np
img = np.zeros((5, 5, 3), dtype='u1')
a = (1, 2, 3)
b = (3, 2, 1)
img[1:4, 1:4] = a
img[1, 1] = b
pat = img[1:4, 1:4]
win = np.lib.stride_tricks....
Advice
0
votes
4
replies
85
views
convert a numpy array[N] of 'S{n}' to an array[2*N] of 'S{n/2}'?
I have some code where I read N strings of a given size n into an ndarray, which I would then like to cut in half to obtain a twice longer array of strings size n/2. Is there a numpy operation which ...
-2
votes
0
answers
72
views
Numpy's np.polyfit() returns matching types Error? [closed]
I have a dataTable that is a list of lists. Every one of those lists is a list of different data. The first list containes the year, the second is data about 'poverty' for every one of those years, ...
Advice
1
vote
7
replies
90
views
python: numpy array interface to struct.unpack?
I'm tinkering with some code I found that reads in sound data from (stereo) .wav files, and wonder if there is no way to optimise the reading step.
Currently, it has the form (assuming a basic 16bit ....
3
votes
3
answers
159
views
Calls to Numpy routines from within multiprocessing tasks are very slow
I am calling numpy.linalg.inv from within a multiprocessing task forked from the Python multiprocessing module. I compare the Numpy routine to my own inverse routine my_inv.
What I see is that the ...
0
votes
1
answer
76
views
Filtering numpy array to show when a column is of a certain value or greater [closed]
I am a new python learner, and was using numpy to filter a array of fake information where its formatted in [name, products, price]. I was trying to see a way to filter the array if the products value ...
-4
votes
0
answers
97
views
need help for Data Cleaning and Preprocessing in my project [closed]
import pandas as pd
import numpy as np
import seaborn as sns
df=pd.read_excel('Online_Retail.xlsx')
#Alternative Method to Introduce Missing Values: Using numpy.random.rand
# Make a copy of the ...
2
votes
2
answers
131
views
How to calculate the gradient of a scatter graph?
I have an arguably common problem, but I don't seem to find any instruction on the web. I have a 3D Numpy array containing the coordinates of N points:
In[1]: import numpy as np
In[2]: N = 50
In[3]: ...
0
votes
1
answer
95
views
How can I calculate the gradients efficiently without any NaN outputs? [closed]
I want to calculate partial derivatives which I tried to do using finite difference giving me NaN.
Then I tried using the gradient function, but giving me error as
ValueError: setting an array ...
1
vote
1
answer
104
views
Why does my rotation (up / down) break when I rotate 90 degrees left or right, and how do I fix it?
I'm trying to make a simple 3d renderer in CMU Graphics using rotation matrices. When I rotate the camera 90 degrees (left or right), and I try rotating (up / down), it does a "barrel roll" ...
1
vote
3
answers
188
views
Error while deploying python code to linux based azure function
I am trying to deploy python code to azure function (linux based, python 3.12). The app works if I exclude pandas (and other package dependency). However, I am getting the following error on azure if ...
Advice
1
vote
6
replies
105
views
How to find max value within a specific range
Basically I have a 2D numpy array, the first column being my x-axis values and the second being my y-axis values. I want to find the max value of y within a specified range of x values (there are ...
3
votes
3
answers
118
views
String print format specifier does not work for numpy string array
I am trying to use numpy sort for numpy string array. But, when I try to print them element-wise with string print format specifier '{:s}' it is giving me the following error.
print("{0:s} {1:...
2
votes
1
answer
85
views
NumPy generate a 2d linear array using multiple values
So I'm trying to generate a map for a personal project using opensimplex noise, multiple layers etc.
My problem is that I want to recreate the equator to combine with a temperature map to obviously ...