Penguins 1#

In this quiz we will be looking at exploring the penguins dataset.

../../../../../_images/penguins.png

Part 1#

You can load the penguins dataset in seaborn using:

df = sns.load_dataset("penguins")

This dataset contains information about three species of penguins (Adelie, Gentoo, and Chinstrap), and various characteristics including their bill_length, bill_depth, flipper_length, body_mass, and sex.

Credit: Artwork by [@allison_horst](https://www.allisonhorst.com).

We would like to drop three columns from the dataframe: {{ params.vars.rand_title_1 }}, {{ params.vars.rand_title_2 }}, and {{ params.vars.rand_title_3 }}.

The following code:

df.drop(['{{ params.vars.rand_title_1 }}','{{ params.vars.rand_title_2 }}','{{ params.vars.rand_title_3 }}'])

gives this error:

KeyError: "['{{ params.vars.rand_title_1 }}' '{{ params.vars.rand_title_2 }}' '{{ params.vars.rand_title_3 }}'] not found in axis".

Why is the error happening?

Answer Section#

  • The code above is currently dropping rows, rather than columns.

  • There is a spelling mistake in the names of the columns we’re trying to drop.

  • The .drop() function requires a list of lists, rather than just a list when dropping multiple columns.

  • The .drop() function cannot be used to drop more than one column at a time.

  • None of these options.

Attribution#

Problem is licensed under the CC-BY-NC-SA 4.0 license.
The Creative Commons 4.0 license requiring attribution-BY, non-commercial-NC, and share-alike-SA license.