return pd.Series({'AorB': df.loc[idx, 'A' if col == 'B' else 'B'], 'x': df.
    loc[idx, 'x']})
dfnew.join(dfnew.apply(func, axis=1)).dropna()
Find position of value, that occurs only once in dataframe