title: how to gather DataFrame column into key value pairs as row in python
body: <p>I'm trying to gather a pandas DataFrame column into a key value pairs and list it as a row in python. If we take the following DataFrame as example, I want to go from here:</p>
  
  <pre><code>import pandas as pd
  from collections import OrderedDict
  
  df = pd.DataFrame({'value_2016': [200],
                     'value_2017': [300],
                     'value_2018': [float('NaN')]})
  print(df)
  
       value_2016  value_2017  value_2018
  0         200         300         NaN
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>df_result = pd.DataFrame(OrderedDict({'year': [2016, 2017],
                                        'value': [200, 300]}))
  
  print(df_result)
  
     year  value
  0  2016    200
  1  2017    300
  </code></pre>
  
  <p>If you are familiar in R the equivalent would be something like this:</p>
  
  <pre><code>require("plyr"); require("dplyr"); require(tidyr)
  
  df &lt;- data.frame(value_2016 = 200,
                   value_2017 = 300,
                   value_2018 = NA)
  
  df %&gt;% 
     gather(year, value, value_2016:value_2018) %&gt;% 
     mutate(year = gsub(x = .$year, replacement = "", "value_")) %&gt;% 
     na.exclude
  
       year value
     1 2016   200
     2 2017   300
  </code></pre>
  
  <p>Any help would be very cool!</p>