I got a PhD in Organic Chemistry in 1994. I was a researcher for a few years and converted to software in 2000.
The degree turned out to have a lot of transferable skills - especially in researching and solving problems.
Just 25 years later I am a Principal Engineer in the Oz Telco industry writing Rust!
I don't regret the degree for a moment - although when I went through the degree was free, even at a top tier Australian university.