Handling wasted time
How can I deal with these feelings?

It certainly helps to put things into perspective. In the large scheme of things, 5 years are not much. In these times, it's not uncommon that people make radical career shifts in their 30s or 40s, starting from zero at a much later point in time than you do now.

Also, how should I discuss the wasted time in a job interview?

It's unlikely that this will be addressed, since employees generally care more about &quot;what you bring to the company&quot; than about your personal biography. If they do address it, you're in a comfortable position because you changed your study field. You can explain that you reoriented yourself towards the new study field because it better matched your interests, preferences, and strengths (and recognizing that took some time for significant consideration).
Don't mention the partying and avoid a &quot;wasted time&quot; mindset. A better mindset is that this earlier study period was valuable because it allowed you to recognize what you're good at.