confused with the use of axis in Pandas (Python)
<p>From my understanding, axis=0 is running vertically downwards across rows and axis =1 is running horizontally across columns
for example:</p>

<pre><code>In [55]: df1
    Out[55]:
       x  y  z
    0  1  3  8
    1  2  4  NaN
    2  3  5  7
    3  4  6  NaN
    4  5  7  6
    5 NaN 1  9
    6 NaN 9  5
</code></pre>

<p>so mean across column df.mean(axis=0) gives:</p>

<pre><code>    x  3
    y  5
    z  7
</code></pre>

<p>But if I want to drop missing values by column as</p>

<pre><code>   y
0  3
1  4
2  5
3  6
4  7
5  1
6  9
</code></pre>

<p>then I have to use df.dropna(axis=1) rather than df.dropna(axis=0) to get the output I want, but isn't axis=1 regarding rows, how come it mean columns in this case?</p>

<p>from the pandas documentation:</p>

<pre><code>DataFrame.dropna(axis=0, how='any', thresh=None, subset=None, inplace=False)
"Return object with labels on given axis omitted where alternately
any or all of the data are missing"

Parameters: 
    axis : {0 or âindexâ, 1 or âcolumnsâ}, or tuple/list thereof
    Pass tuple or list to drop on multiple axes
</code></pre>

<p>So the function is defined in a way that <code>axis=1</code> means columns. 
If you want to drop by row you just call it like this:</p>

<pre><code>df_dropped = df.dropna(how='all') # drop by row
</code></pre>

python pandas