All Questions
977 questions
1
vote
1
answer
78
views
Taking values from numpy array using array of indices
I am trying to find a simple numpy command to take the values of an 3D matrix according to an index array for the second coordinate. This can be done as:
import numpy as np
entry = np.array([[1, 2],[3,...
1
vote
2
answers
80
views
Converting an array of floats into RGBA values in an efficient way
I am trying to create a system to take an array of floats which range from 0.0 to 1.0 and convert them into RGBA values based on a lookup table. The output should be an array that is one dimension ...
0
votes
1
answer
73
views
Dynamic input to populate Numpy array without for loop for Monte Carlo
I've got some elegant code from other contributors for a Monte Carlo (random walk) using numpy. However, currently the 'vol,' aka standard deviation, is a supplied constant. Ideally, it should vary ...
0
votes
3
answers
84
views
Indexing overlapping areas of a numpy array
I have a 2D array of zeros (called labels) and a list of its coordinates (called centers). For each of the centers I would like to put a progressive number in a 5x5 cluster around it inside the label ...
1
vote
0
answers
55
views
Why is an array variable not getting updated unless assigning to [:]? [duplicate]
I was solving this leetcode problem of rotating the array right by k places and this is the function I wrote in Python:
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
...
1
vote
1
answer
45
views
How to I remove or update data (not objects) in a class list?
I created the following class:
class myAIS():
def __init__(self, mmsi, Alat, Alon, Aspeed, Acourse, shipname):
self.mmsi=mmsi #integer
self.lat=Alat #float
...
0
votes
1
answer
55
views
Array coordinate treated as sequence
I am inputting a numpy array, which was generated from an image into a function. That function makes an autostereogram by horizontally repeating the image and shifting certain pixels.
This is done ...
-1
votes
3
answers
93
views
Changing array elements by indexing
I have a list/array which has elements which need to be changed now and then. I changed elements in the list by indexing, and when I print out the list, it the changes have been made.
l = stdarray....
0
votes
1
answer
51
views
Find next High/Low in index based on a reference point variable
I'm trying to create a couple of methods that use the mark price of a given ticker and then references the next highest high or lowest low (out of four bars) based on that reference point.
Example:
...
1
vote
1
answer
72
views
Is there a way to efficiently construct a 3d array from symmetric submatrices of a 2d array according to an array of different index sets?
I have a two-dimensional array A, and another two-dimensional array I where each row corresponds to a set of indices with which I want to extract symmetric two-dimensional subarrays from A. I want to ...
0
votes
1
answer
32
views
Selecting Date in Xarray Time Series Data
I have an xarray named wk_conc_avgs with the following structure:
xarray.DataArray'N_CT' juld: 1253 y: 850 x: 994
where juld contains dates of structure "yyyy-mm-dd"
I am trying to index a ...
1
vote
0
answers
64
views
Is there a way of quickly indexing a size by size box for each element inside of 2D square tensor?
Say I have a (N, N) sized 2D square numpy array. I want to quickly find the neighboring square around each index in this array, and store it in a (N, N, 2 * size + 1, 2 * size + 1) tensor. Elements on ...
1
vote
2
answers
128
views
Numpy slicing given row for each column
I have an ... x n x m array, say a, where ... stands for an arbitrary number of additional dimensions. Let's call the n-dimension "rows" and the m-dimension" columns for simplicity, ...
0
votes
1
answer
38
views
Indexing multiple elements in a muldimensional numpy array
I would like to extract elements of a given multidimensional numpy array, using another array of indices. However it doesn't behave in the way I expected. Below is a simple example:
import numpy as np
...
-1
votes
4
answers
198
views
Difference between C array and python array [duplicate]
a=input("type sentence: ")
for i in range(1, 100):
if a[i] == 'a':
print (a[i])
elif a[i] == 'o':
break
According to my experience, in C, we can use a[i] with for ...