title: Return multiple columns / a dataframe in Deedle based on row-wise mapping
body: <p>I want to look at each row in a frame and construct multiple columns for a new frame based on values in that row.</p>
  <p>The final result should be a frame that has the columns of the original frame plus the new columns.</p>
  <p>I have a solution but I wonder if there is a better one. I think the best way to explain the desired behavior is with an example. I'm using <a href="https://github.com/BlueMountainCapital/Deedle/blob/master/docs/content/data/Titanic.csv" rel="nofollow noreferrer">Deedle's titanic data set</a>:</p>
  <pre><code>#r @&quot;F:\aolney\research_projects\braintrust\code\QualtricsToR\packages\Deedle.1.2.3\lib\net40\Deedle.dll&quot;;;
  #r @&quot;F:\aolney\research_projects\braintrust\code\QualtricsToR\packages\FSharp.Charting.0.90.12\lib\net40\FSharp.Charting.dll&quot;;;
  #r @&quot;F:\aolney\research_projects\braintrust\code\QualtricsToR\packages\FSharp.Data.2.2.2\lib\net40\FSharp.Data.dll&quot;;;
  open System
  open FSharp.Data
  open Deedle
  open FSharp.Charting;;
  #load @&quot;F:\aolney\research_projects\braintrust\code\QualtricsToR\packages\FSharp.Charting.0.90.12\FSharp.Charting.fsx&quot;;;
  #load @&quot;F:\aolney\research_projects\braintrust\code\QualtricsToR\packages\Deedle.1.2.3\Deedle.fsx&quot;;;
  
  let titanic = Frame.ReadCsv(@&quot;C:\Users\aolne_000\Downloads\titanic.csv&quot;);;
  </code></pre>
  <p>This is what that frame looks like:</p>
  <pre><code>val titanic : Frame&lt;int,string&gt; =
  
         PassengerId Survived Pclass Name                                                Sex    Age       SibSp Parch Ticket           Fare    Cabin Embarked 
  0   -&gt; 1           False    3      Braund, Mr. Owen Harris                             male   22        1     0     A/5 21171        7.25          S        
  1   -&gt; 2           True     1      Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38        1     0     PC 17599         71.2833 C85   C        
  </code></pre>
  <p>My approach grabs each row, uses some selection logic, and then returns a new row value <strong>as a dictionary</strong>. Then I use Deedle's expansion operation to convert the values in this dictionary to new columns.</p>
  <pre><code>titanic?test &lt;- titanic |&gt; Frame.mapRowValues( fun x -&gt; if x.GetAs&lt;int&gt;(&quot;Pclass&quot;) &gt; 1 then dict [&quot;A&quot;, 1; &quot;B&quot;, 2] else dict [&quot;A&quot;, 2 ; &quot;B&quot;, 1] );;
  titanic |&gt; Frame.expandCols [&quot;test&quot;];;
  </code></pre>
  <p>This gives the following new frame:</p>
  <pre><code>       PassengerId Survived Pclass Name                                                Sex    Age       SibSp Parch Ticket           Fare    Cabin Embarked test.A test.B 
  0   -&gt; 1           False    3      Braund, Mr. Owen Harris                             male   22        1     0     A/5 21171        7.25          S        1      2      
  1   -&gt; 2           True     1      Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38        1     0     PC 17599         71.2833 C85   C        2      1      
  </code></pre>
  <p>Note the last two columns are <strong>test.A and test.B</strong>. Effectively this approach creates a new frame (A and B) and then joins the frame to the existing frame.</p>
  <p>This is fine for my use case but it is probably confusing for others to read. Also it forces the prefix, e.g. &quot;test&quot;, on the final columns which isn't highly desirable.</p>
  <p>Is there a way to append the new values to the end of the row series represented in the code above by x?</p>