Exercise

Extracting string patterns

The Length column in the hiking dataset is a column of strings, but contained in the column is the mileage for the hike. We're going to extract this mileage using regular expressions, and then use a lambda in pandas to apply the extraction to the DataFrame.

Instructions

100 XP
  • Search the text in the length argument for numbers and decimals using an appropriate pattern.
  • Extract the matched pattern and convert it to a float.
  • Apply the return_mileage() function to each row in the hiking["Length"] column.