Skip to content

Tag: numpy

Finding the index of minimum value in a row in numpy array

I can’t seem to get my head around how to do this – I am new to Python and this kind of work with arrays. I have a large array, say: I would like to find the column index of the minimum value in each row. For instance for the first 3 rows would give [2, 4, 3….]. I have

How to guess the numerical Solution for Mathieu’s Equation

am trying to predict the exact solution for the mathieu’s equation y”+(lambda – 2qcos(2x))y = 0. I have been able to get five eigenvalues for the equation using numerical approximation and I want to find for each eigenvalues a guessed exact solution. I would be greatfull if someone helps. Th…

Getting indices of ascending order of list

I know that this question has been asked a hundred times, but the answer always seems to be “use numpy’s argsort”. But either I am misinterpreting what most people are asking, or the answers are not correct for the question. Whatever be the case, I wish to get indices of a list’s ascen…

Change np.seterr behavior inside a function only

I want to change the floating point error handling of numpy inside of a single function. Typical example: I would like the call to fto not change the output of np.seterr(), I have no idea how to do this. Thanks for any help ! Answer Use the numpy.errstate context manager to change floating-point error handlin…

How to move a column in a pandas dataframe

I want to take a column indexed ‘length’ and make it my second column. It currently exists as the 5th column. I have tried: I see the following error: TypeError: must be str, not list I’m not sure how to interpret this error because it actually should be a list, right? Also, is there a gener…