@@ -456,7 +456,7 @@ Exercises 3
456456
457457 nobel.groupby(['bornCountry', 'category']).size()
458458
459- - (Optional) Create a pivot table to view a spreadsheet like structure, and view it
459+ - ** (Optional) ** Create a pivot table to view a spreadsheet like structure, and view it
460460
461461 - First add a column “number” to the nobel dataframe containing 1’s
462462 (to enable the counting below). We need to make a copy of
@@ -467,15 +467,17 @@ Exercises 3
467467
468468 - Then create the :meth: `~pandas.DataFrame.pivot_table `::
469469
470- table = subset.pivot_table(values="number", index="bornCountry", columns="category", aggfunc=np.sum)
470+ table = subset.pivot_table(
471+ values="number", index="bornCountry", columns="category", aggfunc="sum"
472+ )
471473
472- - (Optional) Install the ** seaborn ** visualization library if you don't
474+ - ** (Optional) ** Install the `` seaborn `` visualization library if you don't
473475 already have it, and create a heatmap of your table::
474476
475477 import seaborn as sns
476478 sns.heatmap(table,linewidths=.5);
477479
478- - Play around with other nice looking plots::
480+ - ** (Optional) ** Play around with other nice looking plots::
479481
480482 sns.violinplot(y=subset["year"].dt.year, x="bornCountry", inner="stick", data=subset);
481483
@@ -485,8 +487,14 @@ Exercises 3
485487
486488 ::
487489
488- subset_physchem = nobel.loc[nobel['bornCountry'].isin(countries) & (nobel['category'].isin(['physics']) | nobel['category'].isin(['chemistry']))]
489- sns.catplot(x="bornCountry", y="year", col="category", data=subset_physchem, kind="swarm");
490+ subset_physchem = nobel.loc[
491+ nobel['bornCountry'].isin(countries) & (
492+ nobel['category'].isin(['physics']) | nobel['category'].isin(['chemistry'])
493+ )
494+ ]
495+ sns.catplot(
496+ x="bornCountry", y="year", col="category", data=subset_physchem, kind="swarm"
497+ );
490498
491499 ::
492500
0 commit comments