Coding Exercise: Conditional Selection with where

Objective:

Learn how to use the where() function in pandas to filter rows based on specified conditions.

Instructions:

  1. Use the where() function to filter rows where:

  2. Replace values that do not meet the condition with NaN.

  3. Display the rows of the filtered data.

Python Code:

filtered_age = df.where(df['Age'] > 30)

filtered_age