All Questions
Tagged with performance numpy
239
questions
6
votes
1
answer
124
views
Code optimisation: Converting dataframe to numpy's ndarray
I am working with a dataframe of over 21M rows.
...
1
vote
1
answer
2k
views
Count the number of neighbors
I have a numpy array called contour of \$N\$ coordinates (x,y) of dimension (N, 2).
For each ...
1
vote
1
answer
111
views
Getting the square of the difference between many points in a NumPy array
I have an array with 40000 numbers that are floats or ints. I need to perform some calculation.
To do this I have used nested for loop, but the code is really slow. Can I use something instead of ...
4
votes
1
answer
286
views
Generating unique 2D numpy arrays with 2 adjacent row elements swapped while using BFS in Python
So I have a 12 x 6 2D numpy array for input which consists of 7 possible board objects (characters from 'abcdefg'). From a 2D numpy array I wish to generate all the possible unique 2D arrays, in whose ...
0
votes
1
answer
526
views
Image color-moment extractor [closed]
I was just wondering if there is a way to speed up the performances of this for loops in Python.
I'm trying to process an image to get the color-moments without using libraries.
It takes about 12sec ...
2
votes
0
answers
80
views
Profiling for Bézier curve calculations
Recently I posted an answer on a question about Bézier curve calculations. As a micro-synopsis: there are three implementations of De Casteljau's algorithm here, including the original poster's, AJ ...
3
votes
1
answer
245
views
Fast way to calculate Standing Wave modes in NumPy
I am trying to plot the standing wave modes in a 2D box over time. The equation for this is:
$$ A(x,y,t) = \sum\limits_{n,m} sin \left( \frac{n \pi x}{L_x} \right) sin \left( \frac{m \pi y}{L_y} \...
4
votes
1
answer
156
views
Code for wireless communication work
I need some pointers on how I can speed up my code, as of now it is incredible slow for larger inputs. The way the code works is that the file Loc_Circle_50U.txt contains the true locations of 50 ...
2
votes
1
answer
774
views
Building optimal portfolios for all combinations of stocks
Hi I recently wrote some code in python that does the following:
1.) Pulls stock closing data from yahoo finance for x number of stock
2.) finds all possible combinations of x stocks in groups of y ...
5
votes
1
answer
264
views
Binning whilst avoiding the need for for-loops in Python?
I am working on a relatively simple binning program, where I take a 5D array and bin it based on two 3D arrays to create a contour plot. See the sample code below. In actuality, my arrays are of size <...
2
votes
1
answer
241
views
AI In 2048 Game, Calculations so slow
Inspired by this answer on stackoverflow for AI implementation in 2048 game.
I have been trying to make AI calculate best move by playing the game given specific times in memory preceding by one ...
-1
votes
1
answer
49
views
Trying to get every 6th set of 4 bytes from a python array [closed]
I have an array of bytes 6144 bytes long. I want to extract a set of 4 bytes every 6th set of 4 bytes . So every 24 bytes I want to extract 4 of those bytes and join them in a new array. So
...
5
votes
2
answers
419
views
Loop through group and difference lags
I have time-series data (t) that I want to loop through each t and take the difference of the previous five lags ...
1
vote
1
answer
422
views
Asteroids using pygame
I made the looks of asteroids using pygame. I still need to implement collisions but since it is running incredibly slow with 'amount' anything above 10. Please rip ...
10
votes
2
answers
1k
views
Generating large testing datasets
I have made a small Python script that will generate some test sets for my project.
The script generates 2 datasets with the same dimensions n*m. One contains ...