Guided Project: Star Wars Survey My work

A review is kindly needed.

link to the project

https://app.dataquest.io/m/201/guided-project%3A-star-wars-survey/9/next-steps

star wars prject file

Star wars.ipynb (487.0 KB)

Done with the project including extra suggestions to be added.

please i will need a review on how to improve my work. I got lots of help from this community on shared projects. Some of my final codes insight are gotten from a shared project here.

Regards

Click here to view the jupyter notebook file in a new tab

1 Like

Hi @Sahil

Thank for the help so far.

while working on the project, i needed a way to represent this code below using an iteration function but i couldnt think of how to figure it out.

fig, ax = plt.subplots(figsize=(28,18))
characters = star_wars_characters_rate.columns.values
len_char = np.arange(len(characters))
bar_w = .85

#lets calculate the percentage of the 4 major groups
Favorably = ((star_wars_characters_rate ==
Preformatted text ‘Favorably’).sum()/star_wars_characters_rate.shape[0]) * 100
Unfavorably = ((star_wars_characters_rate ==
‘Unfavorably’).sum()/star_wars_characters_rate.shape[0]) * 100
Neutral = (star_wars_characters_rate ==
‘Neutral’).sum()/star_wars_characters_rate.shape[0] * 100
Unknown = (star_wars_characters_rate ==
‘Unknown’).sum()/star_wars_characters_rate.shape[0] * 100

plt.bar(len_char, Favorably[len_char], color=(26/255,255/255,26/255), width = bar_w)
plt.bar(len_char, Neutral[len_char], bottom=Favorably[len_char], color=(86/255,180/255,233/255), width = bar_w)
plt.bar(len_char, Unknown[len_char], bottom=(Favorably[len_char]+ Neutral[len_char]), color=(240/255,228/255,66/255), width = bar_w)
plt.bar(len_char, Unfavorably[len_char], bottom=(Favorably[len_char]+ Neutral[len_char] + Unknown[len_char]), color=(254/255,58/255,0/255), width=bar_w)
plt.xticks(len_char+.35, characters)
plt.yticks(np.arange(20, 120, 20))

ax.tick_params(bottom=‘off’, top=‘off’, left=‘off’, right=‘off’)

for key, spine in ax.spines.items():
spine.set_visible(False)

plt.legend(bbox_to_anchor=(1.05, 1), loc=‘upper left’, borderaxespad=0., labels=(‘Favorably’, ‘Neutral’, ‘Unknown’, ‘Unfavorably’), ncol=1, fancybox=True, framealpha=.6)


is there a shorter way to do this??Preformatted text

loved your visual representation, very clear and neat! great work :wink:

1 Like