lst = df.A.values.tolist()
n = len(lst)
lengths = [len(sub) for sub in lst]
flat = np.concatenate(lst)
u, inv = np.unique(flat, return_inverse=True)
rng = np.arange(n)
slc = np.hstack([rng.repeat(lengths)[:, (None)], inv[:, (None)]])
data = np.zeros((n, u.shape[0]), dtype=np.uint8)
data[slc[:, (0)], slc[:, (1)]] = 1
pd.DataFrame(data, df.index, u)
Create new columns in pandas from python nested lists