What is axis in Python with Numpy module?
Question: when I use np.stack, sometimes have to use axis, like axis=1. I don't
understand what the axis means for it. for exmaple,

    
    
    c1 = np.ones((2, 3))
    c2 = np.zeros((2, 3))
    c = np.stack([c1, c2], axis = 1)
    

this shows like,

    
    
    array([[[1., 1., 1.],
            [0., 0., 0.]],
    
           [[1., 1., 1.],
            [0., 0., 0.]]])
    

what rules make the result?


Answer: Axis means the dimension . For a simple example consider
[numpy.sum](http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.sum.html)

    
    
    import numpy as np
    a=np.array([1,2,3],[2,3,1])
    sum1=np.sum(a,axis=0)
    sum2=np.sum(a,axis=1)
    print sum1,sum2
    

This will give me sum1=12 and sum2=[3,5,4]

My array has two dimensions/axis. The first one is of length 2 and the second
one is of length 3. So by specifying axis you simpy tell your code along which
dimension you want to do your job.

[numpy.ndarray.ndim](http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.ndim.html)
can tell you how many axes do you have

