Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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 :: save python plot 
Python :: python polymorphism 
Python :: python inspect module 
Python :: python multiprocessing queue 
Python :: remove nan from list 
Python :: transpose of a matrix in python using loop 
Python :: remove outlier using IQR 
Python :: scikit decision tree regressor 
Python :: change value in dataframe 
Python :: python sort array by lambda 
Python :: how to make one list from nested list 
Python :: Adding new column to existing DataFrame in Pandas 
Python :: remove dict python 
Python :: split long list into chunks of 100 
Python :: matplotlib set colorbar range 
Python :: python chatbot error 
Python :: how to sort nested list in python 
Python :: how to read frame width of video in cv2 
Python :: python selenium print xpath of element 
Python :: characters python 
Python :: random.choices without repetition 
Python :: search an array in python 
Python :: np.random.randint 
Python :: what does tuple mean in python 
Python :: initialize variable python 
Python :: import turtle 
Python :: python pattern 
Python :: how to make a do while in python 
Python :: python discord bot embed 
Python :: diccionario python 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =