Changing Data Types with astype
📖 Scenario: You work in a small store and keep track of sales data. Sometimes the numbers are saved as text, but you need them as numbers to do math.
🎯 Goal: You will change the data types of sales data from text to numbers using astype so you can analyze it easily.
📋 What You'll Learn
Create a pandas DataFrame with sales data as strings
Create a list of columns to convert
Use
astype to change the data types of those columns to integersPrint the DataFrame to see the changes
💡 Why This Matters
🌍 Real World
Stores and businesses often get data as text but need numbers to calculate totals, averages, or do other analysis.
💼 Career
Data analysts and scientists frequently convert data types to prepare data for calculations and visualizations.
Progress0 / 4 steps