115,264 questions
0
votes
1
answer
75
views
KDTree 2d index searching based on pivot_table vector error
i want find 2d index(from PCA). based on pivot_table vector at my custom metric. fastly. that's why im using KDTree. but because it, these error is occur:
ValueError Traceback (most recent call last)
...
Best practices
1
vote
13
replies
164
views
Series cancelations accumulate errors, how to avoid?
import math
import matplotlib.pyplot as plt
import numpy as np
m=50
def taylor_cos(x,n):
sum=0
for i in range(0, n):
sum=sum+ (((-1)**i) * (x**(2*i)) / math.factorial(2*i))
...
1
vote
1
answer
183
views
Python/numpy - 2D FFT does not recover the analytical solution
I am working on a code that calculates the 2D FFT of a function as a first step. I am testing it with the function exp(-r)/r, with r=sqrt(x²+y²) which has the analytical Hankel transform of 1/sqrt(r²+...
Best practices
0
votes
6
replies
88
views
Is there a simple way to take bitwise-and of a pandas series?
I have a pandas series of a bunch of 32 bit integers, and I'd like to roll through with series.rolling and get the bitwise-and of all the values in the window, basically trying to do this except that ...
Advice
0
votes
1
replies
105
views
How should a beginner approach learning NumPy before using it with real datasets
I’m a beginner learning NumPy and Data Science. I understand basic operations such as array creation, indexing, slicing, and simple computations.
However, when I try to follow tutorials that use NumPy ...
Best practices
0
votes
4
replies
104
views
Efficient, parallelized graph6 parsing with numpy or SIMD?
I have a multigraph class in Python that is used as a base for simple undirected, unlooped graphs.
I wrote my own graph6 parser based on the advice in the SO post.
NetworkX implements it in a similar ...
Advice
0
votes
2
replies
103
views
Python mandelbrot set iteration slider
I've got a class project to do, it's supposed to display the mandelbrot set with a customizable colour map and a max_iter slider. I've got the colour map radio buttons working, but I can't manage the ...
-5
votes
2
answers
194
views
How can I remove unnecessary layers from a nested array? [closed]
I have a "deeply nested" NumPy array like this:
array = [
[
[
[ "data . . . "],
]
],
[
...
3
votes
2
answers
113
views
How to visualize a dense, gappy time series with spikes in Python?
I have a sensor time series with these properties:
~250,000 data points at high sampling rate over ~12 hours
~11 continuous segments separated by 30-40 minute gaps (sensor goes offline periodically)
...
4
votes
3
answers
176
views
Rotating NumPy indices to produce a rotated image works only in two of four segments
I'm working on a Python program that calculates images by some function frame by frame to create a video.
Sometimes images need to be rotated (without cropping them). First, I rotated images as ...
Advice
0
votes
3
replies
77
views
Subtracting a blank spectrum from a sample in Raman spectroscopy data
I have two sets of Raman spectroscopy data:
Orange: the blank (background signal)
Blue: the actual sample (contains both sample signal and blank signal)
I am not very familiar with Python. I was ...
Advice
0
votes
3
replies
78
views
How to make a 3D plot from a 3D numpy array
I would like to make a 3D surface plot (ideally like the one seen here https://matplotlib.org/stable/gallery/mplot3d/contour3d_3.html) from a 3D array.
How do I take one 3D array and create the three ...
Best practices
2
votes
1
replies
99
views
Can i make a Neural network And simply ML Model using a smartphone? (Ain't Have Pc/Laptop Btw)
I am someone who is currently Learn Python, especially libary for make machine learn, but i am not have pc/laptop , can i make my own ML & Neural model?
I haveI've heard that we can use Google ...
0
votes
0
answers
97
views
Why does np.vectorize promotes np.uint8 elements of a 1-d array to int, but leaves types of list elements unchanged? [duplicate]
I have this Python function:
import numpy as np
def f(x):
print(f"x is {x} and has type {type(x)}")
try:
print(f"x.dtype is {x.dtype}")
except AttributeError:
...
3
votes
2
answers
187
views
Why does summing a complex and a np.float64 value give a complex value instead of a np.complex128 value suggested by the Numerical promotion rules?
I am reading about Numerical promotion in numpy. I copy the main graph here:
Based on the graph, this explanation:
The input dtype with the higher kind determines the kind of the result dtype. The ...