Created
April 13, 2022 08:54
-
-
Save Steboss89/13a55214468b5e2e3768dec1e6a1b129 to your computer and use it in GitHub Desktop.
Create a histogram to compare numbers across principal books
This file contains hidden or 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
| df = pd.DataFrame.from_dict(match_dict) | |
| #Extract a subset from the books we want to analyse | |
| books = ['Genesis','Exodus','1Kings','2Kings','Psalms','Isaias','Mark','Matthew','Luke','John','Apocalypse'] | |
| # drop NaN, so where occurrences = 0, so we can have a comparison of the common set of numbers | |
| # transpose the dataframe so numbers will be the name of the columns | |
| subset = df[book].dropna().T | |
| # melt the dataframe | |
| subset = subset.reset_index().melt(id_vars='index') | |
| # rename columns | |
| subset.rename(columns={"index":"Book", "variable":"Number","value":"Occurrence"},inplace=True) | |
| # display | |
| fig, ax = plt.subplots(figsize=(15,15)) | |
| sns.set_theme(style="white", context="talk") | |
| sns.barplot(data=subset, x="Occurrence", y="Number", hue="Book",palette="deep", ax=ax) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment