Project 26: Crypto Prices Melt
Data Analyst
Builds on these lessons
Current Task
Objective
pd.melt() does the opposite of pivot_table: it turns wide columns into long rows, which many plotting and analysis tools prefer.
Task: melt a wide prices DataFrame (one column per month) into a long coin/month/price format and print it.
index.py
import pandas as pd
prices = pd.DataFrame({'coin': ['BTC', 'ETH'], 'jan': [42000, 2200], 'feb': [45000, 2400]})
melted = pd.melt(prices, id_vars='coin', var_name='month', value_name='price')
print(melted)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview