Skip to main content

Questions tagged [numpy-ndarray]

Numpy Ndarray refers to the N-dimensional array type that describes the collection of the same type in the Python library NumPy. Use this tag for questions related to this array type.

numpy-ndarray
1 vote
0 answers
27 views

Storing numpy arrays in PostgreSQL: BYTEA vs. ARRAY for large integer arrays

I'm aware that PostgreSQL supports storing arrays directly. Is it more effective to store large numpy arrays of integers using PostgreSQL's native ARRAY type compared to BYTEA? Specifically, my arrays ...
Kawaruto's user avatar
0 votes
0 answers
14 views

Why reshape is needed for Sequential models after minmaxscaler class? and how to use?

My recent project is based on 'Stock Prediciton" I'm working on df["Open"] as nd.array. Trying to understand intuitively how this works and whether my predicted data will be correct or ...
Shreeya Sharma's user avatar
1 vote
1 answer
49 views

ndarray a obtained from b.diagonal() has its value changed after the b modification

I'm a bit confused by the behavior of the below code and wondering if someone could shed some light on this. Basically, I have a matrix called mat which is a numpy ndarray. I get its diagonal using ...
captain_willard's user avatar
-1 votes
1 answer
57 views

Place pixels on a grid [closed]

I have a two dimensional numpy array: myarray=[[0,0],[1,1],[2,2]] I also have a grid of points: mygrid=[[70,70],[100,100],[30,30]] I want to efficiently create a new array which contains points of ...
100xln2's user avatar
  • 143
0 votes
2 answers
16 views

Extracting the values of Fipy diffusion and convection terms

I am new to Fipy and I was wondering if there is a way how to extract the values of a diffusion or convections terms. in the case of a cell variable this is easy but diffusion or convections are in ...
Abderrezak TORCHE's user avatar
0 votes
1 answer
17 views

Conditionally changing elements of a numpy array using for loop

I have a two dimensional numpy array, and I'm wanting to change all of the 'male' values to 0 and all of the 'female' values to 1. If I try to assign arr2D[row,element] to a specific value, I get an ...
Brandon Harrell's user avatar
4 votes
2 answers
112 views

Optimal multiplication of two 3D arrays having a variable dimension

I would like to multiply tensors R = {R_1, R_2, ..., R_M} and X = {X_1, X_2, ..., X_M} where R_i and X_i are 3×3 and 3×N_i matrices, respectively. How can I make maximum use of NumPy functionalities ...
TobiR's user avatar
  • 143
1 vote
2 answers
84 views

Numba njit making function call involving long expressions extremely slow

I am writing a finite volume code to solve the inviscid, compressible Euler equations. As a part of this, I am performing what is known as the Cauchy-Kovalevskaya process. A code snippet is given ...
Siddharth Yajaman's user avatar
3 votes
2 answers
77 views

Numpy array slicing with a comma

There are multiple questions on StackOverflow, asking how the comma syntax works, but most of them refer to m[:,n] which refers to the nth column. Similarly, m[n,:] refers to the nth row. I find this ...
Shirsak's user avatar
  • 57
2 votes
1 answer
45 views

np.ones(30011,30011) needs 7.2GB, but Task Manager shows 5.3GB

A 30,011x30,011 of 64-bit floats takes 7.2GB. There are many explanations for why one might see np.zeros([30011,30011]) take up (say) a miniscule 0.7MB. However, my Windows 2010 Task Manager also ...
user2153235's user avatar
  • 1,038
1 vote
1 answer
42 views

Simplest equivalent implementation of numpy.ma.notmasked_edges() for use in JAX

I have a square numpy.ndarray and a numpy boolean mask of the same shape. I want to find the first element in each row of the array that is not masked. My code currently relies on numpy.ma....
Ben's user avatar
  • 225
1 vote
1 answer
89 views

NumPy array size and performance differences for int8 vs bool dtype

I am trying to use numpy's nbytes attribute to examine the memory usage of arrays with different dtype. I noticed the following: >>> np.zeros(1024, dtype='int64').nbytes / 1024 # in kB 8.0 ...
Kalo's user avatar
  • 81
0 votes
3 answers
59 views

TypeError: unhashable type: 'numpy.ndarray' in array to set

in this def i get TypeError: unhashable type: 'numpy.ndarray' in line retrieved_indices_set = set(retrieved_indices) def evaluate_retrieval(query_idx, retrieved_indices, relevant_indices): # ...
Erfan Hamidi's user avatar
0 votes
2 answers
52 views

Why is numpy shuffle not working in a loop?

Thanks very much in advance. I have a numpy array called X_test X_test.shape (11829, 16, 9) I am trying to shuffle the 2nd column of each element of the array with the code below. However, X_test_s ...
eng's user avatar
  • 3
0 votes
0 answers
19 views

CFS thredds data don't work in xarray lib

I need to get u,v at 10 meters from CFS thredds from the historic forecast, but, when I open and try to get the variables, the error: FunctionalityNotEnabledError: Functionality not enabled pops. My ...
Pedro Lucas Oliveira Pinto's user avatar

15 30 50 per page
1
2 3 4 5
260