简体   繁体   中英

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

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]]
>>> a - a.min(axis=0)
array([[0, 4],
       [2, 2],
       [4, 0]])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM