Convert List of Associations into Association of Lists

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












For neuralnetworks mathematica likes 2 ways to structure trainingsets:



listFormatData = "Input" -> input2, "OutputKey1" -> OutputKey1Input2Output, ...


and



assocFormatData = <|
"Input" -> input1, input2, ...,
"OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output, ...
, ...
|>


Is the a stock way to convert these 2 formats properly?



concrete examples:



listData = 
<


and



assocData = <|
"Input" -> 1, 2, 3,
"double" -> 2, 4, 6,
"squared" -> 1, 4, 9
|>









share|improve this question





















  • What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
    – J. M. is computer-less♦
    1 hour ago















up vote
2
down vote

favorite












For neuralnetworks mathematica likes 2 ways to structure trainingsets:



listFormatData = "Input" -> input2, "OutputKey1" -> OutputKey1Input2Output, ...


and



assocFormatData = <|
"Input" -> input1, input2, ...,
"OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output, ...
, ...
|>


Is the a stock way to convert these 2 formats properly?



concrete examples:



listData = 
<


and



assocData = <|
"Input" -> 1, 2, 3,
"double" -> 2, 4, 6,
"squared" -> 1, 4, 9
|>









share|improve this question





















  • What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
    – J. M. is computer-less♦
    1 hour ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











For neuralnetworks mathematica likes 2 ways to structure trainingsets:



listFormatData = "Input" -> input2, "OutputKey1" -> OutputKey1Input2Output, ...


and



assocFormatData = <|
"Input" -> input1, input2, ...,
"OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output, ...
, ...
|>


Is the a stock way to convert these 2 formats properly?



concrete examples:



listData = 
<


and



assocData = <|
"Input" -> 1, 2, 3,
"double" -> 2, 4, 6,
"squared" -> 1, 4, 9
|>









share|improve this question













For neuralnetworks mathematica likes 2 ways to structure trainingsets:



listFormatData = "Input" -> input2, "OutputKey1" -> OutputKey1Input2Output, ...


and



assocFormatData = <|
"Input" -> input1, input2, ...,
"OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output, ...
, ...
|>


Is the a stock way to convert these 2 formats properly?



concrete examples:



listData = 
<


and



assocData = <|
"Input" -> 1, 2, 3,
"double" -> 2, 4, 6,
"squared" -> 1, 4, 9
|>






list-manipulation associations neural-networks






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









Gladaed

1427




1427











  • What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
    – J. M. is computer-less♦
    1 hour ago

















  • What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
    – J. M. is computer-less♦
    1 hour ago
















What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
– J. M. is computer-less♦
1 hour ago





What does Normal[Transpose[Dataset[listData]]] return for you? (Also if you replace listData with assocData?)
– J. M. is computer-less♦
1 hour ago











2 Answers
2






active

oldest

votes

















up vote
3
down vote













Merge[listData, Identity]



<|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>




listFormatData = >,
<;
Merge[listFormatData , Identity]



<|"Input" -> input1, input2,
"OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output|>







share|improve this answer



























    up vote
    1
    down vote













    A function that is of great use here, is AssociationTranspose in the GeneralUtilities package. It does the same thing as regular transpose, but works with List and Associations alike (and mixtures of the two):



    listData = >,
    <;
    assocData = <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>;
    GeneralUtilities`AssociationTranspose[listData] === assocData
    GeneralUtilities`AssociationTranspose[assocData] === listData




    Out[11]= True



    Out[12]= True








    share|improve this answer




















      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      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: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184221%2fconvert-list-of-associations-into-association-of-lists%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      Merge[listData, Identity]



      <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>




      listFormatData = >,
      <;
      Merge[listFormatData , Identity]



      <|"Input" -> input1, input2,
      "OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output|>







      share|improve this answer
























        up vote
        3
        down vote













        Merge[listData, Identity]



        <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>




        listFormatData = >,
        <;
        Merge[listFormatData , Identity]



        <|"Input" -> input1, input2,
        "OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output|>







        share|improve this answer






















          up vote
          3
          down vote










          up vote
          3
          down vote









          Merge[listData, Identity]



          <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>




          listFormatData = >,
          <;
          Merge[listFormatData , Identity]



          <|"Input" -> input1, input2,
          "OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output|>







          share|improve this answer












          Merge[listData, Identity]



          <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>




          listFormatData = >,
          <;
          Merge[listFormatData , Identity]



          <|"Input" -> input1, input2,
          "OutputKey1" -> OutputKey1Input1Output, OutputKey1Input2Output|>








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          kglr

          166k8188389




          166k8188389




















              up vote
              1
              down vote













              A function that is of great use here, is AssociationTranspose in the GeneralUtilities package. It does the same thing as regular transpose, but works with List and Associations alike (and mixtures of the two):



              listData = >,
              <;
              assocData = <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>;
              GeneralUtilities`AssociationTranspose[listData] === assocData
              GeneralUtilities`AssociationTranspose[assocData] === listData




              Out[11]= True



              Out[12]= True








              share|improve this answer
























                up vote
                1
                down vote













                A function that is of great use here, is AssociationTranspose in the GeneralUtilities package. It does the same thing as regular transpose, but works with List and Associations alike (and mixtures of the two):



                listData = >,
                <;
                assocData = <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>;
                GeneralUtilities`AssociationTranspose[listData] === assocData
                GeneralUtilities`AssociationTranspose[assocData] === listData




                Out[11]= True



                Out[12]= True








                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  A function that is of great use here, is AssociationTranspose in the GeneralUtilities package. It does the same thing as regular transpose, but works with List and Associations alike (and mixtures of the two):



                  listData = >,
                  <;
                  assocData = <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>;
                  GeneralUtilities`AssociationTranspose[listData] === assocData
                  GeneralUtilities`AssociationTranspose[assocData] === listData




                  Out[11]= True



                  Out[12]= True








                  share|improve this answer












                  A function that is of great use here, is AssociationTranspose in the GeneralUtilities package. It does the same thing as regular transpose, but works with List and Associations alike (and mixtures of the two):



                  listData = >,
                  <;
                  assocData = <|"Input" -> 1, 2, 3, "double" -> 2, 4, 6, "squared" -> 1, 4, 9|>;
                  GeneralUtilities`AssociationTranspose[listData] === assocData
                  GeneralUtilities`AssociationTranspose[assocData] === listData




                  Out[11]= True



                  Out[12]= True









                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 21 mins ago









                  Sjoerd Smit

                  2,985715




                  2,985715



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184221%2fconvert-list-of-associations-into-association-of-lists%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      Installing NextGIS Connect into QGIS 3?

                      One-line joke