 <p>Here:</p> <pre><code>import pandas as pd import numpy as np df = pd.read_csv('inputfile', index_col=None, names=['text']) s = df.text.str.split('|') ds = [dict(w.split('=', 1) for w in x) for x in s] p1 = pd.DataFrame.from_records(ds).fillna('n/a') st = p1.stack(level=0,dropna=False) for k, v in st.groupby(level=0): print(k, v.sort_index()) </code></pre>