Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created July 3, 2019 10:33
Show Gist options
  • Save fclesio/8e330cc714d6d9b879132194f3e9f074 to your computer and use it in GitHub Desktop.
Save fclesio/8e330cc714d6d9b879132194f3e9f074 to your computer and use it in GitHub Desktop.
def get_language(text):
text = str(text)
b = TextBlob(text)
return b.detect_language()
# Include language in the DF
df_raw_lyrics['lang'] = df_raw_lyrics['lyric'].apply(get_language)
# Show stats about the language per artist
df_raw_lyrics.groupby(['artist', 'lang']).size().reset_index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment