Skip to main content

All Questions

Tagged with
4 votes
1 answer
78 views

Array Math to Calculate Ice Thickness -- Need Help Simplifying

I posted this on Stack but since it's working code, it was suggested I post it here. I wrote this code to calculate ice thickness using the following equation from Stephenson, 2011. It's a daily ...
emmahaggerty's user avatar
4 votes
1 answer
130 views

Finding the earliest time we can schedule

We have a list of \$j \in \{1,\ldots,N\}\$ jobs with a processing time \$p_j\$ and a demand \$d_j\$ between 0 and 1. These are real numbers. Jobs require the fixed demand over the entirety of their ...
Titan's user avatar
  • 43
2 votes
1 answer
389 views

Generating random number of randomly sized Squares/Rectangles using numpy arrays

I made classes to use in generating square/rectangular shapes on a texture. ...
Nyos's user avatar
  • 21
2 votes
1 answer
257 views

Replace nested for loops when assigning intial conditions in a 4-dimensional array

I create a 4-dimensional (x, y, z, t) array of zero values. I then set the initial values at t = Tmax. To do this, I use a nested for loop. I attempted to improve ...
Ruan's user avatar
  • 111
2 votes
1 answer
131 views

Minimum re-labeling to make an array as close as possible to another one

I have an array with integer labels in [0, n-1], say arr1=[1, 0, 3, 2] with n = 3. And then I have another array again with integer labels in [0, n-1], say arr2=[0, 0, 2, 3]. How can I find the ...
ApPs's user avatar
  • 23
4 votes
1 answer
105 views

Dataframe transformation to numpy ndarray takes ages to complete

I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
super_ask's user avatar
  • 143
1 vote
1 answer
869 views

Fill missing dates into array of np.datetime

Here is the problem: Given an array of a non-continuous sequence of dates. Make it a continuous sequence of dates, by filling in the missing dates. ...
Levon Avetisyan's user avatar
2 votes
2 answers
790 views

Finding distance between vectors of matrices

So here is the problem: Given 2D numpy arrays 'a' and 'b' of sizes n×m and k×m respectively and one natural number 'p'. You need to find the distance(Euclidean) of the rows of the matrices 'a' and ...
Levon Avetisyan's user avatar
6 votes
3 answers
4k views

Marking duplicate entries in a numpy array as True

So the problem is Find the duplicate entries (2nd occurrence onwards) in the given numpy array and mark them as True. First time occurrences should be False. And my solution is: ...
Levon Avetisyan's user avatar
4 votes
2 answers
400 views

Creating nxm index list of array a

Here is the problem: Given a numpy array 'a' that contains n elements, denote by b the set of its unique values ​​in ascending order, denote by m the size of array b. You need to create a numpy array ...
Levon Avetisyan's user avatar
3 votes
1 answer
73 views

Generating multiple new arrays using numpy

Say I have the following two different states: state1 = [0, 1, 0, 1, 1] state2 = [1, 1, 0, 0, 1] And I want to generate n number of new states by only changing the ...
Omar AlSuwaidi's user avatar
7 votes
2 answers
798 views

How to clean the indexes, and ideally not create an additional array

So I answered this question on SO and probably did someone's homework along the way. In the original question the OP has the answer variable and wants it split to ...
Uberhumus's user avatar
  • 193
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
3 votes
2 answers
537 views

Multiplying numpy arrays

I have written a function to multiply two numpy arrays. ...
GalacticPonderer's user avatar
3 votes
1 answer
71 views

Numpy array slicing/reshape/concatination

I'm sure my question exists on the internet, i just don't know the right formulations. I have a data-sample as input for a NN. This sample has the shape (1, 8, 28, 80). Basically it is 80 timesteps ...
Maikefer's user avatar
  • 133

15 30 50 per page