Normally I anonymize my data by using hashlib and using the .apply(hash) function.
Now im trying a new approach, imagine I have to following df called \'data\':
Maybe try to create a data frame called "index" for this operation and keep unique name values inside it?
Then produce masks with unique name indexes and merge the resulting data frame indexwith data.
index = pd.DataFrame()
index['name'] = df['name'].unique()
index['mask'] = index['name'].apply(lambda x : 'person' +
str(index[index.name == x].index[0] + 1))
data.merge(index, how='left')[['mask', 'amount']]