Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Peyton Runyan DS01 #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Peyton Runyan DS01 #24

wants to merge 7 commits into from

Conversation

peytonrunyan
Copy link

No description provided.

@waterFlowin
Copy link

waterFlowin commented Nov 29, 2018

Sprint Challenge Code Review

Week 2 - Storytelling with Data


Part 0 — Run this starter code


Part 1 — What's the breakdown of guests’ occupations per year?

Code review

What went well:

  • Perfect, just need a space after the comma before df['Occupation']
pd.crosstab(df['Year'],df['Occupation'], normalize='index')


Part 2 — Recreate this explanatory visualization:

Code review

What went well:

  • I like that you did the graph a different way:

Here is a cleaner and more simple code block:

  • You can get the same graph in Matplotlib with:
cross_tab = pd.crosstab(df['Year'],df['Occupation'], normalize='index')
cross_tab = cross_tab.drop('Other', axis=1)
plt.plot(cross_tab['Acting, Comedy & Music'])
plt.plot(cross_tab['Government and Politics'])
plt.plot(cross_tab['Media'])
  • Then just simply add the text parts of the graph:
plt.legend(cross_tab.columns)
plt.text(x=1998, y=1.1, s="Who Got To Be On 'The Daily Show'?", fontweight='bold')
plt.text(x=1998, y=1.0, s='Occupation of guests, by year');


Part 3 — Who were the top 10 guests on The Daily Show?

Code review

What went well:

  • This is correct and well done:
#count the times each guest has appeared
appearances = df.Guest.value_counts()

#return the 10 largest
top_ten = appearances.nlargest(10)

top_ten.plot.bar();

One simple small improvement is to add the rot parameter for readability:

top_ten.plot.bar(rot=45);

One liner Method Chain that does the same bar plot:

df.Guest.value_counts().head(10).plot.bar()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants