Skip to main content

Questions tagged [numpy]

NumPy is one of the many modules in Python that adds support of large multidimensional arrays and matrixes, along with a large library of high-level mathematical functions for operations with these arrays.

2 votes
1 answer
39 views

Numpy: Sum N successive array elements, where N comes from a list

Here is code I am trying to optimize: import numpy as np rng = np.random.default_rng() num = np.fromiter((rng.choice([0, 1], size=n, p=[1-qEff, qEff]).sum() for n in num), dtype='...
rad's user avatar
  • 179
1 vote
1 answer
71 views

How do I effectively compute pairwise quantities in numpy?

I want to compute pairwise quantities, e.g. distances between two points. A simple example would be import numpy as np N = 9 x = np.linspace(0,1,N) y = np.abs(x - x[:,None]) # pairwise 1d eucdlidian ...
knods's user avatar
  • 23
0 votes
1 answer
35 views

Unable to install numpy through terminal using pip

I'm trying to install the python package numpy with no luck. I'm using pip install numpy in the terminal, but it returns the following error message: WARNING: Retrying (Retry(total=0, connect=None, ...
asrnpr666's user avatar
1 vote
0 answers
109 views

ModuleNotFoundError: No module named 'numpy._core'

I am trying to load a .npy file created on my local PC with np.save() in google colaboratory. However, when I try to open it on Google Colab with np.load() I get this error: ModuleNotFoundError: No ...
tymerius's user avatar
0 votes
2 answers
68 views

How to transform nested arrays by extending the dimension of the array

Suppose I have an array X with N elements. I would like then to input this array into a 2D array A as follows X=np.array([0,1,2,3],dtype=np.float64) A=np.array([[0,0,X], [0,X,0]],dtype=np....
J.Agusti's user avatar
  • 173
0 votes
1 answer
44 views

What is the meaning of: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data) and how can be solved?

I'm trying to model a time series for a stock price with the following code: import opendatasets as od import numpy as np import pandas as pd import plotly.graph_objects as go from plotly.subplots ...
José's user avatar
  • 201
-2 votes
1 answer
42 views

I'm getting an "src is not a numerical tuple" for an opencv program I'm developing that works in their official documentation but not for me [closed]

I'm creating a python program and trying to get feed from a camera and then perform a fourier transform on it to see its spectrum. I've been trying to initialize the camera with cv2.imread() but for ...
Midkhat Satdanov's user avatar
-2 votes
0 answers
15 views

pyassimp.errors.AssimpError: assimp library not found [closed]

(CGIP) ┏[vbk16] ┖[E:\6th Sem\CG\Mini_Project]> python .\Program.py Traceback (most recent call last): File "E:\6th Sem\CG\Mini_Project\Program.py", line 7, in <module> import ...
VELUPUGONDA BHAVANI KRISHNA's user avatar
0 votes
1 answer
55 views

Efficient stochastic numerical integration over many trajectories

I am implementing a numerical method for solving stochastic differential equations using the Euler-Maruyama method. What I have works, but it is not efficient. The reason is that because of the ...
J.Agusti's user avatar
  • 173
0 votes
0 answers
20 views

read parquet file in dask and convert them to correct numpy shape

I am reading a parquet file in dask and trying to reshape it to how I want it, but it seems rather impossible (I am quite new to dask too). So, I have a parquet file which has some 8M x 384d numpy ...
JohnJ's user avatar
  • 6,996
0 votes
0 answers
36 views

How do I solve the following error message: SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

I have been trying to run the following code: import pyaudio import numpy as np from math import pi def make_sinewave(frequency, length, sample_rate=44100): length = int(length * sample_rate) ...
user2115136's user avatar
0 votes
1 answer
42 views

How can I deal with passing 360 degrees when I linearly interpolate between two headings?

A part of my python program linearly interpolates between two compass headings. It works fine as long as I don't have to deal with passing through North. Is there a good way to deal with this rather ...
Phillip Dobbs's user avatar
0 votes
0 answers
38 views

Why print(f"{variable = }") in Python 3.12 also prints numpy type?

I noticed, that with Python 3.12 and a numpy.float64 when I simply do a x = numpy.sqrt(3) # type is <class 'numpy.float64'> now print(f"{x = }") # this is printed >>>x = np....
emefff's user avatar
  • 1
0 votes
1 answer
33 views

Computing and Visualizing Linear Trends in Ocean Temperature Data

I have a dataset containing ocean temperature values for the time period 1950-2022, covering the entire globe. My goal is to calculate the linear trend for each surface grid box and visualize the ...
faeze bh's user avatar
3 votes
2 answers
82 views

How can I get the subarray indicies of a binary array using numpy?

I have an array that looks like this r = np.array([1, 0, 0, 1, 1, 1, 0, 1, 1, 1]) and I want an output of [(0, 0), (3, 5), (7, 9)] right now I am able to accomplish this with the following function ...
John's user avatar
  • 13.5k

15 30 50 per page