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:



data schema










share|improve this question









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















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:



data schema










share|improve this question









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













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:



data schema










share|improve this question









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:



data schema







python arrays numpy multidimensional-array






share|improve this question









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.











share|improve this question









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.









share|improve this question




share|improve this question








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














  • 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












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']





share|improve this answer























  • 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


















up vote
0
down vote













You may use np.append method in numpy.
You can check the details in numpy.append






share|improve this answer








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


















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])





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    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
































    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']





    share|improve this answer























    • 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















    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']





    share|improve this answer























    • 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













    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']





    share|improve this answer














    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']






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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


















    • 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












    up vote
    0
    down vote













    You may use np.append method in numpy.
    You can check the details in numpy.append






    share|improve this answer








    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















    up vote
    0
    down vote













    You may use np.append method in numpy.
    You can check the details in numpy.append






    share|improve this answer








    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













    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






    share|improve this answer








    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







    share|improve this answer








    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.









    share|improve this answer



    share|improve this answer






    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


















    • 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










    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])





    share|improve this answer

























      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])





      share|improve this answer























        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])





        share|improve this answer












        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])






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Doug7

        212




        212






















            takeshi6 is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            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.















             


            draft saved


            draft discarded














            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




















































































            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly