🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEpandas

pandas Documentation

📖 INDEX

No matches found.
LOADING ENGINE...

pd.melt()

AI & DATA SCIENCE // pd-melt

Unpivot a DataFrame from wide to long format.

Syntax

melted = pd.melt(df, id_vars=['A'], value_vars=['B', 'C'])

Examples

Example 01Basic Usage
melted = pd.melt(df, id_vars=['A'], value_vars=['B', 'C'])

Best Practices

  • Use vectorized operations over iterations (e.g. iterrows()) for performance.
  • Always verify memory usage when loading large files.