Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

vectorize function python numpy

>>> vfunc = np.vectorize(myfunc)
>>> vfunc([1, 2, 3, 4], 2)
array([3, 4, 1, 2])
Comment

python how to vectorize a function

import numpy as np
import math
from math import *


def h_scalar(x):
    return (1 / sqrt(2 * pi)) * exp(-.50** x ** 2.00)
Comment

python vectorize

import numpy as np

# array
a = np.array(["a b c", "d e f", "h i j"])

# function
replace_space = np.vectorize(lambda x: x.replace(" ", "_"))

# response
print(replace_space(a))

# will return: ['a_b_c' 'd_e_f' 'h_i_j']
Comment

PREVIOUS NEXT
Code Example
Python :: run ansible playbook python 
Python :: f string python 
Python :: python turtle tutorial 
Python :: python 2d array 
Python :: make a tuple 
Python :: how to earn money as a python developer 
Python :: select multi columns pandas 
Python :: __dict__ 
Python :: plotly change legend name 
Python :: How to solve not in base 10 in python when using decimals 
Python :: xml to python list in python 
Python :: polls/models.py 
Python :: merge sort in python 
Python :: how to slice list 
Python :: standard error of mean 
Python :: função map python 
Python :: how to test that an exception was raise using pytest 
Python :: python package install 
Python :: second highest value in list python 
Python :: pop element from list python 
Python :: indent python code 
Python :: np.divide 
Python :: django context data 
Python :: how to change datatype of column in pandas 
Python :: get row count dataframe pandas 
Python :: web3.py failing not installing 
Python :: join mulitple dataframe pandas index 
Python :: how to change the starting number for the loop count in pythin 
Python :: pandas math operation from string 
Python :: how to print on same line python 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =