merge two dataframe columns into 1 in pandas
<p>I have 2 columns in my data frame and I need to merge it into 1 single column</p>

<pre><code>Index  A             Index   B
0      A             0       NAN
1      NAN           1       D
2      B             2       NAN
3      NAN           3       E
4      C             4       NAN
</code></pre>

<p>there will always be one 1 value across the Columns, i want my result to look like</p>

<pre><code>0    A
1    B
2    C
3    D
4    E
</code></pre>

<p><strong><em>Option 1</em></strong></p>

<pre><code>df.stack().dropna().reset_index(drop=True)

0    A
1    D
2    B
3    E
4    C
dtype: object
</code></pre>

<p><strong><em>Option 2</em></strong>
If Missing values are always alternating</p>

<pre><code>df.A.combine_first(df.B)

Index
0    A
1    D
2    B
3    E
4    C
Name: A, dtype: object
</code></pre>

<p><strong><em>Option 3</em></strong>
What you asked for</p>

<pre><code>df.A.append(df.B).dropna().reset_index(drop=True)

0    A
1    B
2    C
3    D
4    E
dtype: object
</code></pre>

<p><strong><em>Option 4</em></strong>
Similar to 3 but over arbitrary number of columns</p>

<pre><code>pd.concat([i for _, i in df.iteritems()]).dropna().reset_index(drop=True)

0    A
1    B
2    C
3    D
4    E
dtype: object
</code></pre>

python pandas