Skip to main content
The 2024 Developer Survey results are live! See the results

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.

0 votes
0 answers
8 views

In a dataframe,replace values ​from one column with multiple conditions and not in the same row to another column

I am trying to transfer values ​​from one column to another column in a dataframe, with multiple conditions and not in the same row. Values from Columns 'BEGUZ_H' and 'ENDUZ_H' to Columns 'BEGUZ' and '...
mxplk's user avatar
  • 57
0 votes
0 answers
15 views

Why does `blake2b` on a `numpy` array give different results in different machines?

I ran the following code in two different machines: import numpy as np from hashlib import blake2b print(blake2b(np.array([1, 2, 3])).hexdigest()) The two machines print a different result. Why ...
Ray Bern's user avatar
  • 125
0 votes
0 answers
21 views

Does Image.fromarray works only with numpy.array objects?

That's a simple question, but I'm using numpy for the first time so I'm quite confused. I think I understand the how should it works: my function named img_PILarray below creates an array object ...
gravy's user avatar
  • 1
0 votes
1 answer
42 views

Numpy 2 has a separate float64(nan) - how to get rid of it?

It appears that Numpy 2 introduced its own separate float64(nan) - different from np.nan. Now regression tests fail because while >>> np.nan is np.nan True we now have >>> np.nan is ...
sds's user avatar
  • 59.5k
0 votes
0 answers
23 views

Pandas check if a column has NaT type, unable to find date diff with NaT values [duplicate]

I have StartDate and ExitDate two columns in my dataframe with NaT values in ExitDate column I wish to create a third column Tenure by finding Difference between ExitDate and StartDate. StartDate ...
Vinita's user avatar
  • 1,842
0 votes
0 answers
19 views

Numpythonic way construct windowed vector from desired timestep and window size [duplicate]

Given parameters timestep = 2 window_size = 3 I have flatenned vector of timeseries with size 9. The content is: arr = np.array([1,2,3,4,5,6,7,8,9]) How to reshape/construct windowed timeseries with ...
Muhammad Ikhwan Perwira's user avatar
2 votes
1 answer
48 views

Speed up / parallelize multivariate_normal.pdf

I have multiple Nx3 points, and I sequentially generate a new value for each from its corresponding multivariate Gaussian, each with 1x3 mean and 3x3 cov. So, together, I have arrays: Nx3 array of ...
Valeria's user avatar
  • 1,614
2 votes
3 answers
87 views

vectorize an Ax=b solver

A lot of numerical solvers (such as this one), for some reason, only supports solving Ax=b where x, b are vectors. What if I want to solve AX = B, where X and B are matrices. I know numerically one ...
Taylor Fang's user avatar
-2 votes
1 answer
36 views

Numpy ModuleNotFound after installation

I installed numpy and ran the following code: import numpy a = numpy.array([1,2,3,4]) I'm getting this error: PS C:\Users\Gmellenor\Desktop\visial> & C:/Users/Gmellenor/AppData/Local/Programs/...
gmellenor's user avatar
1 vote
1 answer
36 views

Detect precision loss in numpy floats

If the difference between two numbers is too large, the smallest number will be "lost". Does this raise any flag that I can check? In float32, the significant has 24 binary digits, therefore ...
David Davó's user avatar
3 votes
3 answers
52 views

Why my np.gradient calculation in R^2 doesn't fit with the analytical gradient calculation?

I'm trying to compute a gradient on a map using np.gradient, but I'm encountering issues. To simplify my problem I am trying on an analytical function z = f(x,y) = -(x - 2)**2 - (y - 2)**2 np....
rthgtr Gaehgq's user avatar
4 votes
1 answer
60 views

Convert '3' to numpy.dtypes.Int64DType

I have strings containing str representations of numpy values. I also have a list of the original dtypes, such as numpy.dtypes.Int64DType. I do not know all possible dtypes in advance. I can for the ...
Eike P.'s user avatar
  • 3,453
1 vote
0 answers
20 views

pycharm Unresolved attribute reference 'astype' for class 'ndarray'

Q: How can I fix the bug where Pychram warns about numpy.ndarray attributes? The code runs with no problem, however pycharm keeps giving this warning Unresolved attribute reference 'astype' for class '...
Electron X's user avatar
2 votes
2 answers
41 views

numpy 2d array into block matrix

Given a 2x6 array like below x = np.array([[0,1,2,3,4,5],[6,7,8,9,10,11]]) How do I convert this in to 6x6 matrix with block diagonal filled with above array Input output I am expecting I got the ...
XYZ's user avatar
  • 384
0 votes
0 answers
18 views

Plotting Eigen-energies using QuTip

I am trying to plot the eigen-energies of the following Hamiltonian $$ H = 2\tau \cos(\frac{eA}{hc} \sin(\omega t) + k) $$ Here \tau value is set to 1. A is the amplitude. e,h,c are electron charge, ...
strings's user avatar

15 30 50 per page