Skip to content

Instantly share code, notes, and snippets.

@datacorner
Last active May 17, 2018 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save datacorner/1ed413dcd1c75c2a973d296700e09fc3 to your computer and use it in GitHub Desktop.
Save datacorner/1ed413dcd1c75c2a973d296700e09fc3 to your computer and use it in GitHub Desktop.
Draw 1 histogram with string labels in Python matplotlib
# Where matplotlib do not work (when using string labels for hist())
from collections import Counter
def hist_string(df) :
distincts_count = Counter(df)
df = pd.DataFrame.from_dict(distincts_count, orient='index')
df.plot(kind='bar')
hist_string(titanic.Embarked)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment