Method 1 (OP)
pd.DataFrame([[item]+list(df.loc[line,'B':]) for line in df.index for item in df.loc[line,'A']], columns=df.columns)
Method 2 (feast)
df1 = df.A.apply(pd.Series).stack().rename('A') df2 = df1.to_frame().reset_index(1, drop=True) df2.join(df.B).reset_index(drop=True)
Method 3 (feast)
A = np.asarray(df.A.values.tolist()) B = np.stack([df.B for _ in xrange(A.shape[1])]).T P = np.stack([A, B]) pd.Panel(P, items=['A', 'B']).to_frame().reset_index(drop=True)
Thanks @ user113531 for the link to Alexander's answer. I had to change it to work.
Method 4 (@Alexander) RELATED ANSWER
(Follow the link and above if this was helpful)
rows = [] for i, row in df.iterrows(): for a in row.A: rows.append([a, row.B]) pd.DataFrame(rows, columns=df.columns)
Delays
Method 4 (Alexander) is best followed by Method 3

piRSquared
source share