title: Averaging with Linq while ignoring 0s cleanly
body: <p>I have a linq statement that averages the rows in a DataTable and displays them on a chart, grouped by date and time of day. </p>
  
  <p>There are 1 big problem: there are many 0 values that are returned, due to particular times of day simply not having anything going on. These are skewing my averages something awful</p>
  
  <p>Different times of day may have 0s in different columns, so I can't just delete each row with a 0 in the columns (cleanly), as I would end up with no rows left in the datatable, or at least I can't think of a clean way to do it in any case.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>            var results = from row2 in fiveDayDataTable.AsEnumerable()
                            group row2 by ((DateTime)row2["TheDate"]).TimeOfDay
                                into g
                                select new
                                {
                                    Time = g.Key,
                                    AvgItem1 = g.Average(x =&gt; (int)x["Item1"]),
                                    AvgItem2 = g.Average(x =&gt; (int)x["Item2"]),
                                    AvgItem3 = g.Average(x =&gt; (int)x["Item3"]),
                                    AvgItem4 = g.Average(x =&gt; (int)x["Item4"]),
                                    AvgItem5 = g.Average(x =&gt; (int)x["Item5"]),
                                };
  </code></pre>
  
  <p>I don't know if this is possible, so I figured I would ask- is there a way to do the average without the 0s? </p>
  
  <p>Thank you!</p>