The mean inside func isn't the same as the mean outside. When you assign mean = ... inside func, you are creating a new variable in func's local scope - this mean is completely different from the mean defined outside, in global scope. Furthermore, the local variable with the same name hides the global variable, so in the end, the global variable is not touched.
The basic fix would be to declare mean as a global variable inside func and use the out param:
mean = np.empty(...)
def func(a):
global mean
np.mean(a, axis=0, out=mean) # you don't need the trailing semicolon either
However, for the sake of maintainable code I'd recommend not working with global variables at all when you can avoid it. Instead pass a as a parameter to func and return the result:
def func(a):
return np.mean(a,axis=0)
mean = func(a)
The only event I'd recommend the former method is when it would make more sense performance wise. However, for a simple thing like computing the mean, why even declare a function in the first place?