0
0
Data Analysis Pythondata~15 mins

Why engineered features improve analysis in Data Analysis Python - See It in Action

Choose your learning style9 modes available
Why Engineered Features Improve Analysis
📖 Scenario: Imagine you work in a small online store. You have data about customers and their purchases. You want to understand which customers are likely to buy more. Sometimes, the original data is not enough. You can create new data from the old data. This is called feature engineering. It helps to find better answers.
🎯 Goal: You will create a new feature from existing data and see how it helps to understand customer behavior better.
📋 What You'll Learn
Create a dictionary with customer names and their total purchase amounts
Create a threshold variable to separate high and low spenders
Create a new dictionary with a feature showing if a customer is a high spender
Print the new dictionary to see the result
💡 Why This Matters
🌍 Real World
In real business, creating new features from raw data helps to find useful insights faster and improves decision making.
💼 Career
Data scientists and analysts often engineer features to improve models and reports, making their work more effective.
Progress0 / 4 steps
1
Create the initial customer purchase data
Create a dictionary called customer_purchases with these exact entries: 'Alice': 120, 'Bob': 75, 'Charlie': 200, 'Diana': 50, 'Evan': 180
Data Analysis Python
Hint

Use curly braces {} to create a dictionary. Separate each customer and purchase amount with a colon and commas.

2
Set a threshold to identify high spenders
Create a variable called high_spender_threshold and set it to 100
Data Analysis Python
Hint

Just assign the number 100 to the variable high_spender_threshold.

3
Create a new feature to mark high spenders
Create a new dictionary called customer_features using a dictionary comprehension. Use for customer, amount in customer_purchases.items(). For each customer, set the value to True if amount >= high_spender_threshold, else False
Data Analysis Python
Hint

Use a dictionary comprehension with {customer: (amount >= high_spender_threshold) for customer, amount in customer_purchases.items()}.

4
Print the new features dictionary
Write a print statement to display the customer_features dictionary
Data Analysis Python
Hint

Use print(customer_features) to show the dictionary.