<jupyter_start><jupyter_text>Lecture 7   Census<jupyter_code>full = Table.read_table('nc-est2014-agesex-res.csv')
full
partial = full.select('SEX', 'AGE', 'POPESTIMATE2010', 'POPESTIMATE2014')
partial
simple = partial.relabeled('POPESTIMATE2010', '2010').relabeled('POPESTIMATE2014', '2014')
simple
simple.sort('AGE', descending=True)<jupyter_output><empty_output><jupyter_text>Line Plots<jupyter_code>no_999 = simple.where('AGE', are.below(999))
everyone = no_999.where('SEX', 0).drop('SEX')
everyone
# Arguments are horizontal axis variable, vertical axis variable
everyone.plot('AGE', '2010')
# That plot should be labeled! Here are 3 ways to label it:
# US Population  <--- Just add a comment

everyone.plot('AGE', '2010')
everyone.plot('AGE', '2010')
print('US Population')  # <--- Print out what it is
everyone.plot('AGE', '2010')
plots.title('US Population');    # <--- OPTIONAL; not needed for our course
# Examine the steep dropoff in population
everyone.where('AGE', are.between(60, 71))
2010 - 63
# If given one argument, 'plot' puts that on the x-axis, all other columns plotted on the y-axis
everyone.plot('AGE')<jupyter_output><empty_output><jupyter_text>Males and Females in 2014<jupyter_code>males = no_999.where('SEX', 1).drop('SEX')
females = no_999.where('SEX', 2).drop('SEX')
pop_2014 = Table().with_columns(
    'Age', males.column('AGE'),
    'Males', males.column('2014'),
    'Females', females.column('2014')
)
pop_2014
pop_2014.plot('Age')
total = pop_2014.column('Males') + pop_2014.column('Females')
pct_female = pop_2014.column('Females') / total * 100
pct_female
pct_female = np.round(pct_female, 3)
pct_female
pop_2014 = pop_2014.with_column('Percent female', pct_female)
pop_2014
pop_2014.plot('Age', 'Percent female')<jupyter_output><empty_output><jupyter_text>Scatter Plots<jupyter_code>actors = Table.read_table('actors.csv')
actors
actors.scatter('Number of Movies', 'Total Gross')
actors.scatter('Number of Movies', 'Average per Movie')
actors.where('Average per Movie', are.above(400))<jupyter_output><empty_output><jupyter_text>Bar Charts<jupyter_code>top_movies = Table.read_table('top_movies_2017.csv')
top_movies
top10_adjusted = top_movies.take(np.arange(10))
top10_adjusted
millions = np.round(top10_adjusted.column('Gross (Adjusted)') / 1000000, 3)
top10_adjusted = top10_adjusted.with_column('Millions', millions)
top10_adjusted
# A line plot doesn't make sense here: don't do this!
top10_adjusted.plot('Year', 'Millions')
top10_adjusted.barh('Title', 'Millions')
# Generate the chart shown in the slides:
# bar chart of age (# years since release) for the 10 highest grossing movies (non-adjusted)
top10 = top_movies.sort('Gross', descending = True).take(np.arange(10))
top10 = top10.with_column('Age', 2020 - top10.column('Year'))
top10
top10.barh('Title', 'Age')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15205913410770855, 'fraction_numerical': 0.06441393875395987, 'mean_word_length': 7.005633802816901, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '355980', 'license': 'CC0-1.0', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1003, 'n_words': 221, 'path': 'lec/lec07.ipynb', 'repo_name': 'DrRossTaylor/intro-DS-Assignments', 'size': '2841'}