Using applymap() for DataFrame-wide Operations
📖 Scenario: You work in a small grocery store. You have a table showing the prices of different fruits in different stores. You want to increase all prices by 10% to prepare for a sale.
🎯 Goal: You will create a table of fruit prices, set a price increase rate, use applymap() to increase all prices, and then show the new prices.
📋 What You'll Learn
Create a pandas DataFrame called
prices with exact fruit prices for three stores.Create a variable called
increase_rate with the value 1.10.Use
applymap() with a lambda function to multiply each price by increase_rate and save it as new_prices.Print the
new_prices DataFrame.💡 Why This Matters
🌍 Real World
Stores often need to update prices for all products quickly. Using applymap() helps apply changes to every price in a table easily.
💼 Career
Data analysts and scientists use pandas and applymap() to clean and transform data tables efficiently.
Progress0 / 4 steps