Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy python find minimum value of each column and subtract this value from each column

Tags:

python

numpy

Can anyone help with a snippet of code using numpy and python?

Given an numpy array such as

a = array([[1,11], [3,9], [5,7]]

I want to find the minimun value of each column, so 1 and 7 and then subtract this value from the respective columns,

a = array([[0,4], [2,2], [4,0]]
like image 592
S0rin Avatar asked Nov 03 '11 12:11

S0rin


1 Answers

>>> a - a.min(axis=0) array([[0, 4],        [2, 2],        [4, 0]]) 

Where axis=0 refers to columns.

like image 67
Sven Marnach Avatar answered Sep 22 '22 06:09

Sven Marnach