Creating DataFrame from NumPy array
📖 Scenario: You work in a small shop and have sales data stored as numbers in a NumPy array. You want to organize this data into a table with labels for each column to understand it better.
🎯 Goal: Create a pandas DataFrame from a given NumPy array and add column names to make the data easy to read.
📋 What You'll Learn
Create a NumPy array named
sales_data with the exact values [[10, 20, 30], [15, 25, 35], [20, 30, 40]]Create a list named
columns with the exact values ['Monday', 'Tuesday', 'Wednesday']Create a pandas DataFrame named
df from sales_data with columns set to columnsPrint the DataFrame
df to display the table💡 Why This Matters
🌍 Real World
Organizing raw numerical data into tables helps businesses analyze sales, inventory, or customer information clearly.
💼 Career
Data scientists and analysts often convert arrays or raw data into DataFrames to prepare for analysis and visualization.
Progress0 / 4 steps