Skip to content

Instantly share code, notes, and snippets.

@brenoimatos
Created January 7, 2021 20:54
Show Gist options
  • Save brenoimatos/6583ead3909bfa8a0030449a8c69db3f to your computer and use it in GitHub Desktop.
Save brenoimatos/6583ead3909bfa8a0030449a8c69db3f to your computer and use it in GitHub Desktop.
df['Unique'] = df['tokens'].apply(lambda x: len(set(x)))
df['Total'] = df['tokens'].apply(lambda x: len(x))
df['Relative'] = df['tokens'].apply(lambda x: len(set(x))/len(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment