Skip to content
Advertisement

Tag: arrays

np.where for 2d array, manipulate whole rows

I want to rebuild the following logic with numpy broadcasting function such as np.where: From a 2d array check per row if the first element satisfies a condition. If the condition is true then return the first three elements as a row, else the last three elements. A short MWE in form of a for-loop which I want to circumvent:

Iteratively apply a function to an array

I want to create an array that contains g^0, g^1, g^2…. up to g^100 but all to mod50 (apologies if anyone knows how to format this so the powers are properly aligned I need a bit of help!) In my case g = 23, so I would want an array that looks like: I’ve included all my (incorrect) code at

Add in-between steps into array of numbers (Python)

I am looking for some function that takes an input array of numbers and adds steps (range) between these numbers. I need to specify the length of the output’s array. Example: Result: Is there something like that, in Numpy for example? I have a prototype of this function that uses dividing input array into pairs ([0,2], [2,5], [5,8]) and filling

UFuncTypeError: Cannot cast ufunc ‘det’ input from dtype(‘O’) to dtype(‘float64’) with casting rule ‘same_kind’? How to avoid this issue?

I’m trying to build a PDE in python. I’m new to this and wondering where I have gone wrong. Would appreciate some help. I understand that I have a python object and I’m trying to cast it to a float64 but is there any way around this? Here is my error Here is my code Answer A symbolic calculation like

Compare values within a certain timeframe in arrays

I am trying to compare values (0’s and 1’s) in a array. I want to search for each “1” that appears in one column, for another “1” in the other column in a specific timeframe (for example, 5 seconds, 10 seconds, etc.). I will call the 1’s as “signals”. In example, I have an array such as: data1 = [

Advertisement