I am trying to find a more efficient way to return the index of unique values in a pandas df
For the df below I want to return the index of the first time a unique value occurs.
import pandas as pd
import numpy as np
d = ({
'Day' : ['Mon','Mon','Tues','Mon','Tues','Wed'],
})
df = pd.DataFrame(data=d)
I can manually counti the index of unique value and return below:
first = df.iloc[0].Location
second = df.iloc[2].Location
third = df.iloc[5].Location
I was thinking of doing something like
first = (df['Day'] == 'Mon')
But I still have to change this to find the 2nd, 3rd unique value. Is there a more efficient method?