<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Load the pandas and matplotlib libraries2&nbsp;&nbsp;Do a boxplot of SAT verbal scores3&nbsp;&nbsp;Show some descriptives on weeks worked4&nbsp;&nbsp;Do boxplots of weeks worked5&nbsp;&nbsp;Show some descriptives for the Covid data6&nbsp;&nbsp;Do boxplots of cases and deaths per million7&nbsp;&nbsp;Show the boxplots as separate subplots on one figure  Load the pandas and matplotlib libraries<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
# pd.set_option('display.width', 80)
# pd.set_option('display.max_columns', 7)
# pd.set_option('display.max_rows', 200)
# pd.options.display.float_format = '{:,.0f}'.format
import watermark
%load_ext watermark

%watermark -n -i -iv
nls97 = pd.read_csv('data/nls97.csv')
nls97.set_index('personid', inplace=True)
covidtotals = pd.read_csv('data/covidtotals.csv', parse_dates=['lastdate'])
covidtotals.set_index('iso_code', inplace=True)<jupyter_output><empty_output><jupyter_text>Do a boxplot of SAT verbal scores<jupyter_code>nls97['satverbal'].describe()
plt.figure(figsize=(7, 7))
plt.boxplot(nls97['satverbal'].dropna(), labels=['SAT Verbal'])
plt.annotate('outlier threshold',
             xy=(1.05, 780),
             xytext=(1.15, 780),
             size=7,
             arrowprops=dict(facecolor='black',
                             headwidth=2,
                             width=0.5,
                             shrink=0.02))
plt.annotate('3rd quartile',
             xy=(1.08, 570),
             xytext=(1.15, 570),
             size=7,
             arrowprops=dict(facecolor='black',
                             headwidth=2,
                             width=0.5,
                             shrink=0.02))
plt.annotate('median',
             xy=(1.08, 500),
             xytext=(1.15, 500),
             size=7,
             arrowprops=dict(facecolor='black',
                             headwidth=2,
                             width=0.5,
                             shrink=0.02))
plt.annotate('1st quartile',
             xy=(1.08, 430),
             xytext=(1.15, 430),
             size=7,
             arrowprops=dict(facecolor='black',
                             headwidth=2,
                             width=0.5,
                             shrink=0.02))
plt.annotate('outlier threshold',
             xy=(1.05, 220),
             xytext=(1.15, 220),
             size=7,
             arrowprops=dict(facecolor='black',
                             headwidth=2,
                             width=0.5,
                             shrink=0.02))
plt.title('Boxplot of SAT Verbal Score')
plt.show()<jupyter_output><empty_output><jupyter_text>Show some descriptives on weeks worked<jupyter_code>weeksworked = nls97.loc[:, ['highestdegree', 'weeksworked16', 'weeksworked17']]
weeksworked.describe()<jupyter_output><empty_output><jupyter_text>Do boxplots of weeks worked<jupyter_code>plt.figure(figsize=(9, 9))
plt.boxplot([
    weeksworked['weeksworked16'].dropna(),
    weeksworked['weeksworked17'].dropna()
])
plt.show()<jupyter_output><empty_output><jupyter_text>Show some descriptives for the Covid data<jupyter_code>totvars = ['total_cases', 'total_deaths', 'total_cases_pm', 'total_deaths_pm']
totvarslabels = ['cases', 'deaths', 'cases per million', 'deaths per million']
covidtotalsonly = covidtotals[totvars]
covidtotalsonly.describe()<jupyter_output><empty_output><jupyter_text>Do boxplots of cases and deaths per million<jupyter_code>fig, ax = plt.subplots(figsize=(8, 10))
plt.title('Boxplots of Covid Cases and Deaths Per Million')
ax.boxplot(
    [covidtotalsonly['total_cases_pm'], covidtotalsonly['total_deaths_pm']],
    labels=['cases per million', 'deaths per million'])
plt.tight_layout()
plt.show()<jupyter_output><empty_output><jupyter_text>Show the boxplots as separate subplots on one figure<jupyter_code># fig, axes = plt.subplots(2, 2, figsize=(8, 10))
fig, axes = plt.subplots(2, 2)
plt.suptitle('Boxplots of Covid Cases and Deaths')
axes = axes.ravel()

for j, ax in enumerate(axes):
    ax.boxplot(covidtotalsonly.iloc[:, j], labels=[totvarslabels[j]])
plt.tight_layout()
fig.subplots_adjust(top=0.94)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13161014939530472, 'fraction_numerical': 0.03509603983874793, 'mean_word_length': 2.9383753501400562, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '132345', 'license': 'MIT', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1368, 'n_words': 260, 'path': 'src/datacleaning/Chapter 5/2_boxplots.ipynb', 'repo_name': 'vidyabhandary/DataScienceNotebooks', 'size': '4217'}