There are only two hard things in Computer Science: cache invalidation and naming things.
It might not be the most obvious name for a function, but any time I use pandas melt method, it always brings a smile to my face. Polar’s unpivot is probably a more obvious and consistent name (no surprise there, polars has great naming!) but let’s be honest, it’s not as fun!
Anyway, I got really curious and decided to go deep on why pandas melt is called melt. Github took me as far back as the original function commit, but that doesn’t really make any reference to naming. Looking around a little bit more though, turned up that R’s reshape2 and before that reshape package have a melt function that predates the pandas one! Aha!
Searching turned up this paper which explained the metaphor - ‘melting’ and then ‘casting’ a dataframe, a bit like you might melt and cast metal. And by ‘you’, I guess only ‘you’ if you’re reading this and own or have access to a smelter.
Sadly, it doesn’t go into the full detail of what I watned - why was this name chosen instead of say, unpivot. melt is way more fun a name than a data manipulation function has a right to be!
Buuut, looking up the documentation for the original reshape turned up gold. Or at least, gold for people who are way too into researching function names. Right on the front page it says:
Please note that after the publication of this paper I changed reshape to cast, and deshape to melt to avoid a name conflict with base R
So there we go! The origins of the melt/cast name out of the remains of a name conflict. And yes, yes I did go way to in depth in finding the answer to this question.