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><code>dropna()</code> drops the <strong>labels</strong> on the given axis so <code>df.dropna(axis=1)</code> means "look at the labels across axis 1 (i.e. x, y, and z) and drop that label if there are any NaN in that column"</p>

python pandas