I’m currently working with DICOM files and the TensorFlow IO library for DICOM files seems to throw some errors. So what I was originally doing was this: Anyways, I instead decided to load the DICOM files with pydicom, which seems to work loading the data into a numpy array. Yet, when I create a tensor …
Tag: numpy
TypeError: ‘<' not supported between instances of 'numpy.ndarray' and 'int' with a csv file
I am trying to find specific elements (those with a value less than 5) in a particular data column from an imported csv file. However I keep encountering this strange error. The code reads as follows: Answer Apparently you are doing: I’m a little surprised that it isn’t complaining about instances…
Numpy Mean element wise over 3D arrays
I want to take the mean of 9 arrays element wise so to have one I need something fast. The first bit of code takes forever. And with numpy mean without specifying an axis I get one value. I dont want to specify an axis. I want to take the mean element by element. with output: juneMean[‘wind’][:,:,…
Merge 3 Arrays 2D arrays Dimension Wise to make a 6D array
so I have three Arrays of dimension (1949, 2649) When I do I get (3, 1949, 2649) However I actually want shape (1949, 2649, 1949, 2649, 1949, 2649) instead Answer
Conditional formatting of arrays in Numpy Python
I am trying to make a function where if the last value of order is 1 then the code will append 1 to orders and then append the number 20 to the value array as well. If the last value is 0 in order then it will append 1 to order and append the number 15 to value. Expected Output:
Python Numpy make a pattern with a square matrix of any dimension
I am having difficulties trying to generate a specific pattern that would work for any square matrix with any square dimension using NumPy For example: User input: n = 3 Output: User input: n = 5 Output: User input: n = 8 Output: Since a square matrix can be generated with any number in the form of (n x n),
Loading multiple 2d arrays with different shapes into a new array on a third dimension
I’m currently struggling with a probably rather simple question but I can’t get my head around it. Assuming I have the follow two 2d arrays with different shapes, I can combine them into a new array using: So far so good! But how would I do this if I have a large list where I’d have to itera…
How to using numpy.argsort on a 2D array to sort another 2D array
I use numpy.argsort all the time for 1D data, but it seems to behaving differently in 2D. For example, let’s say I want to argsort this array along axis 1 so the items in each row are in ascending order All fine so far. Each row in the above gives the order to how the columns should be rearranged in
sum the elements of 2 NumPy arrays
I am trying the sum the elements of these arrays…..but it is throwing this error in jupiter notebook Answer You first need to append the two arrays together, then you can take the total sum.
How to get all values in an array whose added index size is greater than value?
I have a 5×5 ndarray and want to sum up all values whose added index size is greater than a given value. For example, I have the following array and want to sum all values whose row and column index is, combined, larger than 6. If I do this manually, I would calculate because 4 + 3, 4 + 4