The goal is to create a dictionary from a pandas column (series) where the keys are the unique elements of the column, and the values are the row indices in which the elements occur. I currently have code that accomplishes this, but I'm wondering if there is a simpler and less hacky way to do it:
df = pd.DataFrame(np.random.randint(0,100,size=(1000, 4)), columns=list('ABCD'))
idx = df['A'].reset_index().groupby('A')['index'].apply(tuple).to_dict()