Skip to content

Tag: numpy

Select multiple ranges of columns in Pandas DataFrame

I have to read several files some in Excel format and some in CSV format. Some of the files have hundreds of columns. Is there a way to select several ranges of columns without specifying all the column names or positions? For example something like selecting columns 1 -10, 15, 17 and 50-100: I need to know h…

Skip every nth index of numpy array

In order to do K-fold validation I would like to use slice a numpy array such that a view of the original array is made but with every nth element removed. For example: If n = 4 then the result would be Note: the numpy requirement is due to this being used for a machine learning assignment where the dependenc…

Numpy Array Conditional Operation Mask?

Suppose you have an array: a = [ 0,1,0] [-1,2,1] [3,-4,2] And lets say you add 20 to everything b = [ 20, 21, 20] [ 19, 22, 21] [ 23, 16, 22] Now lets say I want to add the resulting b to the original array a but only in cases where a < 0 i.e at the index

Understanding scipy deconvolve

I’m trying to understand scipy.signal.deconvolve. From the mathematical point of view a convolution is just the multiplication in fourier space so I would expect that for two functions f and g: Deconvolve(Convolve(f,g) , g) == f In numpy/scipy this is either not the case or I’m missing an importan…