Created
September 22, 2021 13:26
-
-
Save michelkana/ef2008e261824c07c4c5a7391d65529f to your computer and use it in GitHub Desktop.
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
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
# convert stars' dictionary to pandas dataframe | |
frame = pd.DataFrame(star_table) | |
# format stars' dataframe | |
frame.credits = frame.credits.astype('int') | |
frame.year_born = frame.year_born.astype('int') | |
frame.year_first_movie = frame.year_first_movie.astype('int') | |
# calculate age at first movie | |
frame['age_at_first_movie'] = frame['year_first_movie'] - frame['year_born'] | |
# find former child actors | |
print('{} performers started as child actors'.format(frame[frame.age_at_first_movie <= 12].shape[(0)])) | |
# plot stars' age distribution | |
frame.year_born.hist() | |
# plot credits vs. gender | |
sns.catplot( | |
data=frame, kind="bar", | |
x="gender", y="credits", | |
ci="sd", palette="dark", alpha=.6, height=6 | |
) | |
# plot count of female vs male actors | |
sns.countplot(x="gender", data=frame) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment