Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Consistently replace sensitive data values with UUIDs
| ResourceFunction["PseudonymizeData"][table] replaces strings at level 2 in table with UUIDs such that repeated values are replaced with the same UUID. | |
| ResourceFunction["PseudonymizeData"][table,partspec] replaces data in table with UUIDs such that repeated values are replaced with the same UUID at positions specified by partspec. | 
Replace strings with UUID pseudonyms:
| In[1]:= | ![ResourceFunction[
 "PseudonymizeData"][{{"Jon", 1}, {"Mike", 20}, {"Jon", 2}, {"Mike", 30}}]](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/5a93c824b1a6d054.png)  | 
| Out[1]= |   | 
Replace the first column with UUID pseudonyms:
| In[2]:= | ![ResourceFunction[
 "PseudonymizeData"][{{"Jon", 1}, {"Mike", 20}, {"Jon", 2}, {"Mike", 30}}, {All, 1}]](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/31feba22e725c04c.png)  | 
| Out[2]= |   | 
You can pseudonymize multiple columns and shared values will share UUIDs across columns:
| In[3]:= | ![ResourceFunction["PseudonymizeData"][{
   {"Jon", "Mary", 1},
   {"Mike", "Mary", 20},
   {"Jon", "Kate", 2},
   {"Mike", "Kate", 30}
  } , {All, {1, 2}}] // TableForm](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/63b374502aee3eca.png)  | 
| Out[3]= |   | 
PseudonymizeData can be applied to a Dataset:
| In[4]:= | ![ResourceFunction["PseudonymizeData"][Dataset[ {
   {"Jon", 1},
   {"Mike", 20},
   {"Jon", 2},
   {"Mike", 30}
  } ], {All, 1}]](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/5b411cc11786d7bd.png)  | 
| Out[4]= |   | 
If the data is a list of associations, you can use the key as an index:
| In[5]:= | ![ResourceFunction["PseudonymizeData"][Dataset[{
   <|"Name" -> "Jon", "Value" -> 1|>, <|"Name" -> "Mike", "Value" -> 20|>, <|"Name" -> "Jon", "Value" -> 2|>, <|"Name" -> "Mike", "Value" -> 30|>
   }], {All, "Name"}]](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/5c0055fe70068829.png)  | 
| Out[5]= |   | 
If the first row contains headers you can apply pseudonymization from the second row onwards using Span:
| In[6]:= | ![ResourceFunction["PseudonymizeData"][{
   {"Name", "Value"},
   {"Jon", 1},
   {"Mike", 20},
   {"Jon", 2},
   {"Mike", 30}
  } , {2 ;;, 1}] // TableForm](https://www.wolframcloud.com/obj/resourcesystem/images/8b6/8b623718-bc33-440d-abf7-e786e5ef2c95/2d613b7c515e1fff.png)  | 
| Out[7]= |   | 
This work is licensed under a Creative Commons Attribution 4.0 International License