Filter Products Using str.contains() for Pattern Matching
📖 Scenario: You work in a store's data team. You have a list of products with their names and prices. Your manager wants to find all products that have the word "apple" anywhere in their name, ignoring case. This helps the store quickly see all apple-related products.
🎯 Goal: Build a small program that uses str.contains() to filter product names containing the word "apple" (case-insensitive) and display the filtered list.
📋 What You'll Learn
Create a pandas DataFrame called
products with columns name and price using the exact data provided.Create a variable called
pattern that holds the string 'apple'.Use
str.contains() with pattern and case=False to filter the DataFrame.Print the filtered DataFrame.
💡 Why This Matters
🌍 Real World
Stores and businesses often need to search product lists for specific keywords to analyze or promote certain items quickly.
💼 Career
Data analysts and data scientists use pattern matching in text data to filter and analyze relevant information efficiently.
Progress0 / 4 steps