4.1. Exercises
Datetime Questions
Practice Processing Dates
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.
Make sure you remove the hash (#) symbol in the coding portions of this question. We have commented them so that the line won’t execute and you can test your code after each step.
Use the output of the following code chunk to help answer the next question.
Let’s read in data and parse a datetime column as well as calculate the hockey team’s oldest and youngest player.
Tasks:
- Read in the
canucks.csvfile from the data folder and parse theBirth Datecolumn. Save this as an object namedcanucks. - Find the oldest player’s date of birth and save the Timestamp as
oldest. - Find the youngest player’s date of birth and save the Timestamp as
youngest. - Find the age difference between the two players in years to 2 decimal places. Save this as an object name
age_range. - Display
age_range.