how to understand axis = 0 or 1 in Python
<p>From the documentation, "the first running vertically downwards across rows (axis 0), and the second running horizontally across columns (axis 1)"
And the code is </p>

<pre><code>df1 = pd.DataFrame({"x":[1, 2, 3, 4, 5], 
                    "y":[3, 4, 5, 6, 7]}, 
                   index=['a', 'b', 'c', 'd', 'e'])


df2 = pd.DataFrame({"y":[1, 3, 5, 7, 9], 
                    "z":[9, 8, 7, 6, 5]}, 
                   index=['b', 'c', 'd', 'e', 'f'])
pd.concat([df1, df2], join='inner') # by default axis=0
</code></pre>

<p>since axis=0( which I interpret as column)
 I think concat only considers columns that are found in both dataframes. But the acutal output considers rows that are found in both dataframes.(the only common row element 'y')
So how should I understand axis=0,1 correctly?</p>

<p>Interpret axis=0 to apply the algorithm down each column, or to the row labels (the index).. A more detailed schema <a href="http://stackoverflow.com/a/25774395/624829">here</a>.</p>

<p>If you apply that general interpretation to your case, the algorithm here is <code>concat</code>. Thus for axis=0, it means: </p>

<p><em>for each column, take all the rows down (across all the dataframes for <code>concat</code>) , and do contact them when they are in common (because you selected <code>join=inner</code>).</em> </p>

<p>So the meaning would be to take all columns <code>x</code> and concat them down the rows which would stack each chunk of rows one after another. However, here <code>x</code> is not present everywhere, so it is not kept for the final result. The same applies for <code>z</code>. For <code>y</code> the result is kept as <code>y</code> is in all dataframes. This is the result you have.</p>

python pandas axis