4.1. Exercises

Column Arithmetic Questions

Question 1

What is the result if we multiply 2 columns together using the syntax

df[['Column_A']] * df[['Column_B']]

Creating a New Column

Instructions:
Running a coding exercise for the first time, could take a bit of time for everything to load. Be patient, it could take a few minutes.

When you see ____ in a coding exercise, replace it with what you assume to be the correct code. Run it and see if you obtain the desired output. Submit your code to validate if you were correct.

For this exercise, we are going to create and drop some columns from our dataframe.

Tasks:

  • Create a new column named total_special that is the sum of column sp_attack and sp_defense.
  • Save it, overwriting the dataframe named pokemon.
  • Display the first 5 rows of the dataframe.
Hint 1
  • Are you using pokemon.assign()?
  • Are you saving the new dataframes as the correct names?
  • For the new column does total_special = pokemon['sp_attack'] + pokemon['sp_defense']?
Fully worked solution: