1. सीखें
  2. /
  3. पाठ्यक्रम
  4. /
  5. Preprocessing for Machine Learning in Python

Connected

अभ्यास

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.

निर्देश

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.