Skip to main content
0 votes
1 answer
67 views

Apparently weird condition on inclusion of endpoint in np.arange() [duplicate]

The numpy.arange function takes the three parameters: start, stop, step (positional args.) The default step is 1. Throughout my entire Numpy experience, the last element of the resultant array is not ...
VizDracViz's user avatar
1 vote
0 answers
44 views

PySide6 QImage conversion to PyQtGraph ndarray

I cannot generate a QImage with some text on it, keep it in memory, and then successfully display it on a pyqtgraph.ImageItem which needs it as an np.ndarray import sys import numpy as np import ...
Andrei M.'s user avatar
  • 413
1 vote
1 answer
47 views

Pandas dataframe assign nested list not working

I'm trying to assign a dataframe cell with a nested list: df.loc['y','A'] = [[2]] However, the actual assigned value is [2]. It works expected for [2], [[[2]]], [[[[2]]]], but just not for [[2]] See ...
Jian Wang's user avatar
0 votes
2 answers
53 views

Identify identical vectors as part of a multidimensional dot product

I am wanting to identify identical vectors after a dot product calc. The below works for a single dimension but not multi-dimensionally. Single Dimension a = np.array([0.8,0.5]) b = np.array([0.8,0.5])...
Zac's user avatar
  • 1,637
1 vote
1 answer
52 views

unexpected results when using normal and advanced indexing with numpy

Consider the following: import numpy as np a = np.random.rand(123, 45, 3) print(a[:, :, [0, 1]].shape) # (123, 45, 2) print(a[:, 0, [0, 1]].shape) # (123, 2) print(a[0, :, [0, 1]].shape) # (2, 45)...
lebowski's user avatar
  • 101
5 votes
1 answer
103 views

Is there a Numpy method or function to split an array of uint64 into two arrays of uint32

Say I have an array as follows: arr = np.asarray([1, 2, 3, 4294967296, 100], dtype=np.uint64) I now want two arrays, one array with the lower 32 bits of every element, and one with the upper 32 bits ...
lrdewaal's user avatar
  • 352
1 vote
2 answers
138 views

'numpy.ndarray' object has no attribute 'groupby'

I am trying to apply target encoding to categorical features using the category_encoders.TargetEncoder in Python. However, I keep getting the following error: AttributeError: 'numpy.ndarray' object ...
Ironman's user avatar
  • 13
10 votes
1 answer
604 views

Arrays of size 0 in NumPy

I need to work with arrays that can have zeros in their shapes. However, I am encountering an issue. Here's an example: import numpy as np arr = np.array([[]]) assert arr.shape == (1,0) arr.reshape((...
Ziofil's user avatar
  • 2,137
2 votes
1 answer
122 views

0-dimensional array problems with `numpy.vectorize`

numpy.vectorize conveniently converts a scalar function to vectorized functions that can be applied directly to arrays. However, when inputting a single value into the vectorized function, the output ...
F. X. P.'s user avatar
1 vote
0 answers
44 views

Python Numpy Crash without error or warning with exit code -1073740791 due to _multiarray_umath.cp312-win_amd64.pyd

Numpy library crash without console error or warning constantly In Python Console see notifications either Process finished with exit code -1073741819 (0xC0000005) or Process finished with exit code -...
Антон Орлов's user avatar
3 votes
2 answers
59 views

How to reduce verbosity of self-documenting expressions in Python f-strings?

This script: import numpy as np a = np.array([2, 3, 1, 9], dtype='i4') print(a) print(f'{a=}') produces: [2 3 1 9] a=array([2, 3, 1, 9], dtype=int32) Is there a way to get just a=[2 3 1 9] from {a=}...
Paul Jurczak's user avatar
  • 8,235
0 votes
1 answer
106 views

NumPy Stride Tricks: Is it possible to add the windows back into the original array size at the same location without for loops?

I'm currently trying to implement my own version of 2D Pooling (with channels included) in Python using only NumPy, but I've run into a bit of a roadblock with vectorizing the backpropagation process. ...
user29391104's user avatar
1 vote
1 answer
45 views

removing Nans from a 3D array without reshaping my data

I have a 3D array (121, 512, 1024) made up of frames of 512x1024 images. The bottom several rows of the images have Nans which mess up my processing. I want to remove these and end up with something ...
Spectroscopist1812's user avatar
-1 votes
1 answer
41 views

Sort columns of numpy unitary matrix such that highest element of each column is on the diagonal

Take a unitary matrix U. I want to swap the columns such that the largest element of each column (in absolute value) is on the diagonal (modulo ties). What is the best way to do this in numpy?
Ben's user avatar
  • 377
0 votes
1 answer
50 views

How to get row numbers of maximum elements in a 2D Numpy array? [duplicate]

I have a 2D array a given by: a = np.array([[2, 3, 1, 9], [0, 5, 4, 7], [2, 4, 6, 8]]) [[2 3 1 9] [0 5 4 7] [2 4 6 8]] I would like to get row numbers of maximum elements column-wise, i.e. given ...
Paul Jurczak's user avatar
  • 8,235

15 30 50 per page
1
2 3 4 5
262
X