Midnight on October 21, 2022 was either just another hour of your life, or an incredibly significant moment that you’d been counting down to for months, maybe even years. ICYMI, Taylor Swift dropped a new album, called Midnights, at midnight on the 21st.
Leading up to the release, eagle-eyed Swifties have been clocking the tiniest details — the way Taylor styles her hair, the number of words in an Instagram caption, the color of a phone in a split-second clip — and using them to craft convincing theories about the upcoming music.
Data science is a combination of probability, statistics, software engineering, and business knowledge. A Data Scientist is someone who takes large amounts of information and translates it into something actionable. Using programming languages and other coding tools, Data Scientists can meticulously analyze huge amounts of data and find trends and patterns that humans would miss.
So what’s this got to do with a mega pop star’s music? Well, we know that Taylor intentionally plants Easter eggs about new music years in advance for fans to find.
Taylor described this new album Midnights as “the stories of 13 sleepless nights scattered throughout my life.” One major Midnights clue was that Taylor had sung about “midnight” and “middle of the night” in the lyrics of lots of her songs. When you think about her 18-year music career, there’s a lot of data that could be sprinkled with surprises.
In the new Codecademy case study Analyze Taylor Swift Lyrics with Python, you’ll get to analyze the lyrics of every song in Taylor’s discography leading up to Midnights to look for clues. You’ll use Python and Jupyter Notebooks to take a deep dive into her robust catalog of music, and conduct natural language processing (NLP), a machine learning technique that enables you to process verbal and written language using artificial intelligence, to scour her lyrics.
Using code, you’ll make data visualizations like line charts, rug plots, wordclouds, and pie charts with your findings. Here’s an example of a line chart you’ll make that looks at “night” mentions in lyrics over time:
Curious if Taylor Swift songs mention “night” more than “day”? Look at this graph:
And using sentiment analysis, we can see whether her lyrics tend to be positive or negative. This chart looks at positive sentiment over time:
In this case study, you’ll turn to data to answer other pressing questions like:
- Do Taylor’s albums follow a pattern of mentioning midnight?
- Do the songs that mention “nights” in the lyrics have a positive or negative sentiment?
- What words, overall, does Taylor use the most in her song lyrics?
Before you jump in, you’ll need to have a grasp on Python and NLP. Check out the path Apply Natural Language Processing with Python to learn about the exciting field that combines linguistics, AI, and computer science.
Want to take your TSwift fandom to the next level, but don’t know how to code yet? This is a fun excuse to learn (or begin again)! You can start with any of our Code Foundations courses to get introduced to programming concepts that lay the groundwork for more advanced skills. We also have lots of beginner-friendly data science courses that you can take for free, plus a guide that helps you choose a data science language to learn first. If you’re ready to start learning Python, consider taking our popular course Learn Python 3.
If it’s in your wildest dreams to have a career as a Data Scientist, we can help you get there. The path Data Science Foundations will teach you how to clean and analyze data, and get you ready for a career in data science. Or you could take the Career Path Data Scientist: Natural Language Processing Specialist to learn how to think about, visualize, and analyze data and get started with AI.
The new Codecademy case study Analyze Taylor Swift Lyrics with Python is just one example of how data science can be applied to our interests and daily lives. For more real-world practice using data to forecast outcomes, check out our Practice Projects in Python. If you tuned into the NFL on Thursday night to catch the Midnights Teaser trailer, you might also want to try our case study Analyze NFL Stats with Python — you’ll build a machine learning model that predicts the winners of NFL games.