multidimensional-array

Changing nested element in matrix only using constants python

Changing nested element in matrix only using constants python Question: Hi I was working with a matrix in python call it a : a = [ [0,0,0], [0,0,0], [0,0,0] ] I would like to change the element on the second row in the first column (a[1][0]) to 1 yielding the following result : a = …

Total answers: 3

Cutting an array into consistent pieces of any size, with recursion

Cutting an array into consistent pieces of any size, with recursion Question: The problem is to, given an array, write a generator function that will yield all combinations of cutting the array into consistent pieces(arrays of elements that are consecutive in the given array) of any size and which together make up the whole given …

Total answers: 1

To iterate through a .txt table in python

To iterate through a .txt table in python Question: Student ID, Assignment, Score 123456, Zany Text, 100 123456, Magic 9 Ball, 60 123456, Nim Grab, 80 123456, Dungeon Crawl, 78 123456, Ultimate TODO List, 90 654321, Zany Text, 48 This is the content of the .txt file, I need to iterate through this text and …

Total answers: 3

Computing the mean of an array considering only some indices

Computing the mean of an array considering only some indices Question: I have two 2d arrays, one containing float values, one containing bool. I want to create an array containing the mean values of the first matrix for each column considering only the values corresponding to False in the second matrix. For example: A = …

Total answers: 5

How to use numpy.arange with two other arrays as the start and stop parameter?

How to use numpy.arange with two other arrays as the start and stop parameter? Question: I want to build a 2D-array where the first dimension has the same length as two other arrays and the second dimension is an array created by numpy.arange and based on every element of the other two arrays, where one …

Total answers: 1

How to reverse the elements in numpy.ndarray Python

How to reverse the elements in numpy.ndarray Python Question: I have a numpy.ndarray in Python has the following elements e.g[[-0.85] [ 0.95]]. How can I reverse it so it can be [ [ 0.95][-0.85]]. Keep in mind that the length always two but for sure the values are changing. <class ‘numpy.ndarray’> [[-0.85] [ 0.95]] Asked …

Total answers: 2

Using an Input to Retrieve a Corresponding Element From a 2D Array

Using an Input to Retrieve a Corresponding Element From a 2D Array Question: This might be a really obvious solution to some, but, being pretty new to python, I’m unsure how to do it – In short, I want to take a user’s input, and find the corresponding element on a 2D array, i.e. an …

Total answers: 3

How to get key filtered by its value in multidimensional array Python

How to get key filtered by its value in multidimensional array Python Question: I got this data employee_detail_list = { ‘John Doe’: { ‘name’: ‘EMP-0001’, ‘first_name’: ‘John’, ‘last_name’: ‘Doe’, ‘full_name’: ‘John Doe’, ‘company’: ‘Company 1’ }, ‘Tom Smith’: { ‘name’: ‘EMP-0002’, ‘first_name’: ‘Tom’, ‘last_name’: ‘Smith’, ‘full_name’: ‘Tom Smith’, ‘company’: ‘Company 2’ }, ‘Andrew Sebastian’: { …

Total answers: 2

Using numpy.delete() or any other function to delete from a list of lists/arrays

Using numpy.delete() or any other function to delete from a list of lists/arrays Question: I have the following list, let’s call it R: [(array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), array([100, 101, 102])), (array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]), array([103, 104, 105]))] I want to be able to delete columns …

Total answers: 1