Skip to main content

All Questions

Tagged with
6 votes
1 answer
124 views

Code optimisation: Converting dataframe to numpy's ndarray

I am working with a dataframe of over 21M rows. ...
arilwan's user avatar
  • 161
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 ...
Sword Fish's user avatar
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 ...
Tanvir's user avatar
  • 27
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 ...
OldGrog's user avatar
  • 41
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 ...
Enrico Mosca's user avatar
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 ...
Reinderien's user avatar
  • 62.8k
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} \...
Bahauddin Omar's user avatar
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 ...
user3656142's user avatar
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 ...
JordanCodes's user avatar
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 <...
Taimoor Sohail's user avatar
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 ...
Vicrobot's user avatar
  • 137
-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 ...
Jim Ruxton's user avatar
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 ...
Amstell's user avatar
  • 278
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 ...
Marieke Pasker's user avatar
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 ...
Pavlos Panteliadis's user avatar

15 30 50 per page
1 2 3
4
5
16