简体   繁体   中英

Operations with numpy array elements

Have a numpy array which was created from pandas values.

It looks like this:

array([[ 230.1,   37.8,   69.2],
      [  44.5,   39.3,   45.1],
      [  17.2,   45.9,   69.3],
      [ 151.5,   41.3,   58.5],
      [ 180.8,   10.8,   58.4]])

How can I subtract the np.mean() of it from every single entry of this array?

Thanks in advance!

With - :

a = array([[ 230.1,   37.8,   69.2],
  [  44.5,   39.3,   45.1],
  [  17.2,   45.9,   69.3],
  [ 151.5,   41.3,   58.5],
  [ 180.8,   10.8,   58.4]])
a -= a.mean()

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