Here is the standard example that I would like to apply to a dataframe.
Standard Example applied to an array with Desired output
import numpy as np
A = np.array([9,2,9,5])
C, ia, ic = np.unique(A, return_index=True, return_inverse=True)
print(C)
print(ia)
print(ic)
output
[2 5 9]
[1 3 0]
[2, 0, 2, 1]
How can I expand that example to a dataFrame please?. Conceptually, I would like to achieve the same results but with a dataframe with multiple columns instead of A. The code below did not work for me.
C, ia, ic = np.unique(DF[['column1', 'column2', 'column3']], return_index=True, return_inverse=True)
I also tried the following but i am not sure it is giving me the right answer.
C, ia, ic = np.unique(DF[['column1', 'column2', 'column3']].values, return_index=True, return_inverse=True)
Any help is more than welcome