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")What the rule reports
Section titled “What the rule reports”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.
How to fix it
Section titled “How to fix it”xpd has no automatic fix, so make the change by hand.
Diagnostic message
Section titled “Diagnostic message”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.