Change the active workset

It’s in the api, so you can do it in python:
https://thebuildingcoder.typepad.com/blog/2015/02/revit-2015-r2-and-the-read-write-workset-api.html

Here is a thread about worksets in python, not an answer to your question, but it would be a good start if you are not that familiar with python: