Last active
May 17, 2018 08:21
-
-
Save datacorner/1ed413dcd1c75c2a973d296700e09fc3 to your computer and use it in GitHub Desktop.
Draw 1 histogram with string labels in Python matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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