I have the following data.
new Dictionary<DateTime, Dictionary<string, int>>()
{
{
new DateTime(2020,05,05,10,10,10) ,
new Dictionary<string, int>()
{
{ "Value1", 2 },
{ "Value2", 4 },
{ "ValueXY", 6 },
}
},
{
new DateTime(2020,05,05,10,10,12) ,
new Dictionary<string, int>()
{
{ "Value1", 4 },
{ "Value2", 6 },
{ "ValueABC", 12 }
}
}
};
What I want to do with LINQ is to Group by DateTime, without the seconds, to have a package per minute. Additional the average value for the single keys.
So with the example above, I would get this
new Dictionary<DateTime, Dictionary<string, int>>()
{
{
new DateTime(2020,05,05,10,10,0) ,
new Dictionary<string, int>()
{
{ "Value1", 3 },
{ "Value2", 5 },
{ "ValueABC", 12 },
{ "ValueXY", 6 }
}
}
};
I were able to do the grouping, but I don't get the average part working.
categorie.Value.GroupBy(row => row.Key.AddSeconds(-row.Key.Second));
Any ideas how to do this?