Numpy 2d Array Extrude
I am new to numpy ndarrays and i couldn`t find any solution for my issue. I have say 10 files of floating point data. I apply some operation for every pair of files, that returns 1
Solution 1:
Maybe you can accomplish your goal just using a nested list (https://docs.python.org/3.7/tutorial/datastructures.html#nested-list-comprehensions):
# build a 10x10 matrix withdefaultvalue0
matrix = [[0for i inrange(10)] for j inrange(10)]
# assign the resultto a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
Solution 2:
You may use np.append
method in numpy.
You can check the details in numpy.append
Solution 3:
I think you could do this pretty cleanly with a dictionary like so:
file_pairs_table = {}
file_a = "file_a.txt"
file_b = "file_b.txt"
file_pairs_table[(file_a,file_b)] = np.arange(999) #operation resulting in 1d array here.
Then access the value of the file pair like this:
file_pairs_table[(file_a,file_b)]
>>> array([0,1,...,998])
Post a Comment for "Numpy 2d Array Extrude"