All Questions
101,712
questions
1
vote
1
answer
19
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 '...
0
votes
0
answers
16
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 ...
0
votes
0
answers
22
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 ...
1
vote
1
answer
44
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 ...
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 ...
2
votes
1
answer
49
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 ...
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 ...
-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/...
1
vote
1
answer
37
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 ...
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....
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 ...
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 '...
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, ...
1
vote
0
answers
72
views
How can I use vectorization or is there another way to avoid using a for loop with numpy array?
I have a numpy array that has times in the first column and the other columns contain signal values. The objective is to use a peak finding algorithm for all the signal value columns and get the peaks ...
0
votes
1
answer
30
views
Efficient calculation of volatility using EWMA
I am trying to calculate the volatility using EWMA (Exponentially Weighted Moving Average).
Here is the function I developed:
def ewm_std(x, param=0.99):
n = len(x)
coefs = param ** np.arange(...