In [3]:
import pandas as pd
In [5]:
df = pd.DataFrame([
{'first': 'john', 'last': 'smith', 'height': '180', 'weight': '80'},
{'first': 'jane', 'last': 'doe', 'height': '160', 'weight': '50'}
])
df.head()
Out[5]:
In [6]:
pd.melt(df, id_vars=['first', 'last'])
Out[6]:
In [7]:
pd.melt(df, id_vars=['first'])
Out[7]:
Here's a rel-life example.