Skip to content

pandas/melt-default-names

Pack Severity Fix Versions
pandas info none, edit by hand All versions

melt without var_name names the column of old column names variable, which says nothing about them. Name it with var_name, and name the values with value_name.

long = df.melt(id_vars="id")
long = df.melt(id_vars="id", var_name="year", value_name="sales")

The rule reports melt without var_name, which names the column of old column names variable. The column of their values is named value unless the call passes value_name.

xpd has no automatic fix, so make the change by hand.

melt without var_name calls the column of old column names "variable", which does not say what they are. Name it, as in var_name="year", and name the values with value_name=.

See all rules in the pandas pack.