How to get average of rows, columns in a Numpy array

mean value Numpy array on a row or column

Image for post
Image for post

To get the mean value, you first need to know that axis 1 is assumed as row and axis 0 is assumed as column.

a is an array, so:

np.mean(a, axis=0)

or

np.mean(a, axis=1)

depending on what axis you want to average on.

example:

Written by

Web geek, Self-taught full-stack web developer, Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store