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

Advertisements 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).… 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

Advertisements 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… 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

mysql SELECT AVG() gives different result

Advertisements 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`)… 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"?

Advertisements 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… 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?

Advertisements 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… 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?

Advertisements 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… Read More How can I put the average of the values of nested tuples inside a list into a new list?