Wide to Long Format Conversion
📖 Scenario: You work in a small company that tracks monthly sales data for different products. The sales data is currently stored in a wide format, where each month is a separate column. Your manager wants the data in a long format to analyze trends easily.
🎯 Goal: Convert the sales data from wide format to long format using pandas. You will create a DataFrame, set up the necessary configuration, apply the conversion, and display the final long format data.
📋 What You'll Learn
Create a pandas DataFrame with given sales data in wide format
Create a list of month columns to convert
Use pandas
melt function to convert wide format to long formatPrint the resulting long format DataFrame
💡 Why This Matters
🌍 Real World
Data often comes in wide format from reports or spreadsheets. Converting it to long format helps in easier analysis and visualization.
💼 Career
Data scientists and analysts frequently reshape data to prepare it for analysis, reporting, and visualization tasks.
Progress0 / 4 steps