Numpy 2d array extrude
up vote
0
down vote
favorite
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 1D array.
What I want is to have block matrix A[10x10] with rows and cols are my ten files and every element in that matrix is block of 1D array that results my operation applied to f_i and f_j.
I gues i need some kind of map, so that i could tell "This f_i and f_j result in certain array" and could access this array by f_i, f_j.
What would be the best way to achive this? Endpoint of that task is to output this matrix into csv file.
Data schema:

python arrays numpy multidimensional-array
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
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 1D array.
What I want is to have block matrix A[10x10] with rows and cols are my ten files and every element in that matrix is block of 1D array that results my operation applied to f_i and f_j.
I gues i need some kind of map, so that i could tell "This f_i and f_j result in certain array" and could access this array by f_i, f_j.
What would be the best way to achive this? Endpoint of that task is to output this matrix into csv file.
Data schema:

python arrays numpy multidimensional-array
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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 1D array.
What I want is to have block matrix A[10x10] with rows and cols are my ten files and every element in that matrix is block of 1D array that results my operation applied to f_i and f_j.
I gues i need some kind of map, so that i could tell "This f_i and f_j result in certain array" and could access this array by f_i, f_j.
What would be the best way to achive this? Endpoint of that task is to output this matrix into csv file.
Data schema:

python arrays numpy multidimensional-array
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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 1D array.
What I want is to have block matrix A[10x10] with rows and cols are my ten files and every element in that matrix is block of 1D array that results my operation applied to f_i and f_j.
I gues i need some kind of map, so that i could tell "This f_i and f_j result in certain array" and could access this array by f_i, f_j.
What would be the best way to achive this? Endpoint of that task is to output this matrix into csv file.
Data schema:

python arrays numpy multidimensional-array
python arrays numpy multidimensional-array
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
takeshi6
32
32
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
takeshi6 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago
add a comment |
6
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago
6
6
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
accepted
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 with default value 0
matrix = [[0 for i in range(10)] for j in range(10)]
# assign the result to a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
add a comment |
up vote
0
down vote
You may use np.append method in numpy.
You can check the details in numpy.append
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
add a comment |
up vote
0
down vote
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])
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
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 with default value 0
matrix = [[0 for i in range(10)] for j in range(10)]
# assign the result to a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
add a comment |
up vote
0
down vote
accepted
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 with default value 0
matrix = [[0 for i in range(10)] for j in range(10)]
# assign the result to a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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 with default value 0
matrix = [[0 for i in range(10)] for j in range(10)]
# assign the result to a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
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 with default value 0
matrix = [[0 for i in range(10)] for j in range(10)]
# assign the result to a cell
matrix[1][1] = ['result', 'of', 'some', 'operation']
# retrieve the result
print (matrix[1][1])
#=> ['result', 'of', 'some', 'operation']
edited 2 days ago
answered 2 days ago
iGian
2,2832620
2,2832620
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
add a comment |
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
Thanks for that advice, it seems to work. Guess i just i got confused that using np.ndarrays in my previous calculations means i have to use it till the very end)
– takeshi6
2 days ago
add a comment |
up vote
0
down vote
You may use np.append method in numpy.
You can check the details in numpy.append
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
add a comment |
up vote
0
down vote
You may use np.append method in numpy.
You can check the details in numpy.append
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
add a comment |
up vote
0
down vote
up vote
0
down vote
You may use np.append method in numpy.
You can check the details in numpy.append
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
You may use np.append method in numpy.
You can check the details in numpy.append
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 2 days ago
DwayneChen
11
11
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
DwayneChen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
add a comment |
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I need to insert at certain index, not at the end
– takeshi6
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
I see. Then you can try a 3-d dataframe. But it's not recommended.
– DwayneChen
2 days ago
add a comment |
up vote
0
down vote
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])
add a comment |
up vote
0
down vote
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])
add a comment |
up vote
0
down vote
up vote
0
down vote
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])
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])
answered 2 days ago
Doug7
212
212
add a comment |
add a comment |
takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.
takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.
takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.
takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239103%2fnumpy-2d-array-extrude%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
6
I think it might be better if you give an example with some sample data. Right now it is not completely clear what you aim to do.
– Willem Van Onsem
2 days ago
Added picture representing my issue in EDIT
– takeshi6
2 days ago