It sounds to me like you are describing the very common "spider wobble". Any ball python with the spider gene will do this to varying degrees.

However, overheating can also cause brain damage that results in the same thing. While the spider wobble is well known and harmless for the most part, if your snake does not have spider in it, I would immediately suspect overheating and I'd be all over the enclosure to find out how it happened and prevent it from happening again. Very rarely, exposure to chemicals or chemical vapors can also cause this problem. But unless you have exposed your snake to harsh cleaners or solvents in the enclosure or nearby where it was forced to breathe the vapors for a prolonged time, I can't imagine that is the cause.

Has the snake always done this or is this a recent development? If this is a young snake, or newly purchased and carries spider in it, that is almost certainly your answer. if this is an older animal, or one you have had for a while and you have never seen this, then it may be time to look into possible other causes.

Gale