vals = df.values
if np.isfortran(vals):
    vals_1d = vals.ravel(order='F')
else:
    vals_1d = vals.ravel(order='C')
uniques = pd.unique(vals_1d)
Efficient way to get the unique values from 2 or more columns in a Dataframe