# Calculation of average of all possible slices of 1d-array

I have a (big) 1d array of measurement data. I want to calculate the average for every possible slice defined by a start-index and a stop-index. Like cutting at both ends of my data and average every possible cut. The result should be stored in a square 2D array (actually a triangle, as the start… Read More Calculation of average of all possible slices of 1d-array

# Average number of days between two date columns in MySQL

I need to find the average number of days between date_a and date_b, across all rows. row date_a date_b 1 2011-01-04 2014-01-04 2 2018-12-22 2021-11-19 3 2010-03-14 2011-01-01 The average number of days between date_a and date_b for this set is 817.3 There are around 10k rows in the table. Columns date_a and date_b are… Read More Average number of days between two date columns in MySQL

# Replace None in list with average of last 3 non-None entries when the average is above the same entry in another list

I have two lists: dataa = [11, 18, 84, 51, 82, 1, 19, 45, 83, 22] datab = [1, None, 40, 45, None, None, 23, 24, None, None] I need to replace all None in datab for any instance where the prior 3 entries are > than the data entry (see walk-through example below). Ignore… Read More Replace None in list with average of last 3 non-None entries when the average is above the same entry in another list

# AverageIFS formula to take the average starting with the first positive number and last positive number and include any zeros in that range

I need a dynamic AverageIFS formula that will start taking the average with the first positive number and end the average at the last positive number. I need the formula to include zeros in the average if there are any in between the first and last positive number. Using the attached image as an example,… Read More AverageIFS formula to take the average starting with the first positive number and last positive number and include any zeros in that range

# Average salary for each department

I’m trying to get the average employee salary for each department. I am expecting two rows because one department doesn’t have any employees assigned to it. Can someone please tell me how to rectify this issue. Thanks in advance to all who answer and your expertise. Below is my test CASE and inaccurate result. CREATE… Read More Average salary for each department

# mysql SELECT AVG() gives different result

I tried to calculate the average in two different ways. The result should be the same, but mysql gives different result. data dummy CREATE TABLE `test_avg` ( `dt` varchar(10) NOT NULL, `field1` double NOT NULL, `field2` double NOT NULL, `field3` varchar(2) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; INSERT INTO `test_avg` (`dt`, `field1`, `field2`, `field3`) VALUES… Read More mysql SELECT AVG() gives different result

# How to make my program add the two averages together and calculate one average for the "class"?

I am trying to get my program to add all averages together to generate one big "class" average. The code is only taking the last individual average and dividing that by the number of students in calc_average. Any ideas? Here’s my code: def calc_average(total): return total / student_num def determine_score(grade): if 90 <= grade <=100:… Read More How to make my program add the two averages together and calculate one average for the "class"?

# Is it possible to return integer result from Linq Average method, without casting double result to int?

int[] arr = {1,4,5,6,7,2,4,5,6,8,0}; int averageResult = arr.Average(); //?? How to return Average int result. Without casting/convert In this example, can we obtain int result from Average method, without casting/convert ? >Solution : Average() in LINQ returns double so there is no possibility. If you have problem with code cleanliness or you want to shorten… Read More Is it possible to return integer result from Linq Average method, without casting double result to int?

# How can I put the average of the values of nested tuples inside a list into a new list?

I have a list that looks like this, but much, much longer (1,000,000+ tuples): [(1, (226, 242, 195)), (1, (218, 236, 188)), (1, (219, 235, 188)), (1, (220, 236, 187)), (1, (217, 235, 187)), (1, (216, 232, 185)), (1, (216, 234, 184))] I want to find the average of each value in the nested tuple… Read More How can I put the average of the values of nested tuples inside a list into a new list?