Skip to content

Instantly share code, notes, and snippets.

@sevperez
Created August 24, 2020 21:49
Show Gist options
  • Save sevperez/c094fd7d79fdc37c95635cfed356c244 to your computer and use it in GitHub Desktop.
Save sevperez/c094fd7d79fdc37c95635cfed356c244 to your computer and use it in GitHub Desktop.
# Which characters appear most frequently?
def frequency_count(df, col, limit=10):
return df[col].value_counts().head(limit)
frequency_count(characters, "text")
# Ahab 474
# Stubb 224
# Queequeg 184
# Starbuck 140
# Jonah 81
# Moby Dick 75
# Bildad 70
# Peleg 69
# Pip 68
# Pequod 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment