Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy divide with exception

>>> a = np.array([-1, 0, 1, 2, 3], dtype=float)
>>> b = np.array([ 0, 0, 0, 2, 2], dtype=float)

# If you don't pass `out` the indices where (b == 0) will be uninitialized!
>>> c = np.divide(a, b, out=np.zeros_like(a), where=b!=0)
>>> print(c)
[ 0.   0.   0.   1.   1.5]
Comment

PREVIOUS NEXT
Code Example
Python :: append to list py 
Python :: How to Use Python all() Function to Check for Letters in a String using all function 
Python :: factors for negative number python 
Python :: pandas -inf and inf to 0 
Python :: torch flatten 
Python :: how to read files in python with 
Python :: python tkinter entry hide text 
Python :: get multiple inputs in python using map 
Python :: flatten list python 
Python :: find all indices of element in string python 
Python :: making gifs via python 
Python :: how to select axis value in python 
Python :: split pandas dataframe in two 
Python :: add column to df from another df 
Python :: Read JSON files with automatic schema inference 
Python :: python window icon on task bar 
Python :: selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: 
Python :: to see version matplotlib 
Python :: spark list tables in hive 
Python :: remove special characters from string in python 
Python :: Adding labels to histogram bars in matplotlib 
Python :: python tkinter listbox detect selection change 
Python :: remove duplicates from tuple python 
Python :: instagram python bot 
Python :: depth first search in python 
Python :: print for loop in same line python 
Python :: semicolon in python 
Python :: python get line number x in file 
Python :: ascending, descending dict 
Python :: python advanced programs time module 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =