The unit tests are different than the tests directly in the notebook. There is a pretty obvious pattern to the differences between the “Expected” and “Actual” values. If you pass one test, but fail a different set of tests, then the first thing to consider is whether there is something “hard-coded” about your solution such that it matches the first set of tests. You can also read the unit test code to understand what is different about those tests. Click “File → Open” and then open the file w2_unittest.py.
Sorry, but your logic is incorrect in several ways. E.g. why are you starting with row - 1? The loop is over row, right? That is not all that is wrong. There are several cases in which you are confusing the index of a row with the actual row.
My suggestion would be to start by taking one of the input test cases and actually work out the algorithm step by step with a pencil and paper. Then with that clear in your mind, then work through what your code would do in the same case. Once you have clear what is supposed to be happening, then that needs to inform how you write the code.