I just learned this several days ago: set in python is unsorted and changes from time to time.

For example:

a = [‘a’, ‘b’, ‘b’, ‘c’, ’d’, ’d’, ‘e’]
set(a)

If you run the codes twice (in two different notebooks or scripts), the results are different. To solve this problem:

ls = list(set(a))
ls.sort()
ls