I've seen both males & females of both species (Timneh & red-tailed) do this. I think it is a displaced natural behavior they do when stressed or frustrated. My pet Timneh hen will do this sometimes when I put her in her sleeping cage & she's not quite ready to sleep. She has even continued to dig after the lights are out! She will also do this if she is in her cage and I am eating in the same room her cage is in. Little beggar.
As far as what the natural behavior this is derived from, I have heard many theories from them doing it to rid their nestholes of parasites and or feces, to digging in the ground for grubs. Not sure which.
Does anyone know if other African parrot species do this?