title: Modify List<T> using Linq to Average rows with matching designator
body: <p>I have a .csv file wherein each row of data represents a part and its associated parameters. e.g. Name, Y-Position, etc.
  I have defined a class to represent each part and have already parsed the .csv into <code>List&lt;Part&gt; parts</code></p>
  <p>However, the CSV file contains multiple rows with the same Name. I want to reduce <code>List&lt;Part&gt; parts</code> combining rows of same Name and averaging Y-Position.</p>
  <p>Input: .csv</p>
  <pre><code>Name,XPosition,YPosition
  A,10,1
  B,10,4
  C,10,3
  C,10,5
  D,12,6
  D,12,8
  </code></pre>
  <p>I've created <code>List&lt;Part&gt; parts</code> from this data.</p>
  <p>Desired output: <code>List&lt;Parts&gt; part</code> containing:</p>
  <pre><code>Part { Name=&quot;A&quot;, YPosition=1 },
  Part { Name=&quot;B&quot;, YPosition=4 },
  Part { Name=&quot;C&quot;, YPosition=4 },
  Part { Name=&quot;D&quot;, YPosition=7 }
  </code></pre>
  <p>I've tried:</p>
  <pre><code>List&lt;Part&gt; parts = parts
  .GroupBy(p =&gt; p.Name)
  .Select(g =&gt; new Part()
  {
      Name = g.Key, 
      YPosition = g.Average(p =&gt; p.YPosition)
  }
  foreach (Part g in parts)
  {
      Console.WriteLine(g.Name + &quot;,&quot; + g.XPosition + &quot;,&quot; + g.YPosition);
  }
  </code></pre>
  <p>But XPosition is not passed to parts...</p>