lens = np.array(map(len, sequences))
seq_arr = np.concatenate(sequences)
ids = np.unique(seq_arr, return_inverse=1)[1]
out = np.split(ids, lens[:-1].cumsum())
python pandas/numpy quick way of replacing all values according to a mapping scheme