Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

resample python numpy

def resample(x, factor, kind='linear'):
    n = np.ceil(x.size / factor)
    f = interp1d(np.linspace(0, 1, x.size), x, kind)
    return f(np.linspace(0, 1, n))
 
e.g.:

a = np.array([1,2,3,4,5,6,7,8,9,10])
resample(a, factor=1.5, kind='linear')

yields

array([ 1. ,  2.5,  4. ,  5.5,  7. ,  8.5, 10. ])

and

a = np.array([1,2,3,4,5,6,7,8,9,10])
resample(a, factor=1.5, kind='nearest')

array([ 1.,  2.,  4.,  5.,  7.,  8., 10.])
Comment

PREVIOUS NEXT
Code Example
Python :: python numpy arrays equality 
Python :: pyperclip copy paste 
Python :: how to write to a file in python without deleting all content 
Python :: countplot in pandas 
Python :: how to check if mouse is over a rect in pygame 
Python :: read xls file in python 
Python :: how to get a row from a dataframe in python 
Python :: define variable with if statement python 
Python :: random list python 
Python :: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied. 
Python :: python print unicode character 
Python :: RuntimeError: Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM) 
Python :: how to make a kivy label multiline text 
Python :: get env variable linux python 
Python :: redirect to previous page django 
Python :: python remove n random elements from a list 
Python :: pandas query on datetime 
Python :: format percentage python 
Python :: pd merge on multiple columns 
Python :: get file names in folder python 
Python :: pip install specific version 
Python :: create a list of characters python 
Python :: random hex color python 
Python :: how to fill nan values with mean in pandas 
Python :: python fernet 
Python :: sklearn cross validation score 
Python :: Django - include app urls 
Python :: how to show line chart in seaborn lib 
Python :: How do you find the missing number in a given integer array of 1 to 100? 
Python :: check if back is pressed python 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =