getAverDataPerMonth = function () {
var data = weathInfo23;
const parsedData = data.map(d => ({
month: d.Month,
temperature: d.MeanTemp,
precip: +d.TotalPrecip,
gust: +d.MaxGust
}));
const monthlyInfo = d3.group(parsedData, d => d.month);
const averages = Array.from(monthlyInfo, ([month, values]) => {
const tempAver = Math.round(d3.mean(values, d => d.temperature));
const rainlyDays = Math.round(values.filter(d => d.precip>2).length/10);
const gustDays = Math.round(values.filter(d => !isNaN(d.gust)).length/10);
return {
key: month,
values: [
{ key: 'tempAver', value: tempAver },
{ key: 'rainlyDays', value: rainlyDays },
{ key: 'gustDays', value: gustDays }
]
};
});
return averages
}