Skip to content

Unpivot

Base classes

Name Children Inherits
CallOp
datacook.engine.ops.base
An op that is one pandas call.

⋔ Inheritance diagram

graph TD
  853706299["reshape.Unpivot"]
  3484306131["base.CallOp"]
  1539482213["base.Op"]
  2751680898["builtins.object"]
  3484306131 --> 853706299
  1539482213 --> 3484306131
  2751680898 --> 1539482213

🛈 DocStrings

Bases: CallOp

Source code in src/datacook/engine/ops/reshape.py
class Unpivot(base.CallOp):
    id = "unpivot"
    title = _("Unpivot (melt)")
    description = _(
        "Turn columns into rows: one row per identifier and column, with the column name"
        " and its value (wide to long format)."
    )
    category = categories.RESHAPE
    icon = "mdi.table-arrow-down"
    method = "melt"

    class Params(base.Params):
        id_vars: list[str] = Field(
            [], title=N_("Identifier columns"), json_schema_extra={"widget": "columns"}
        )
        value_vars: list[str] | None = Field(
            None,
            title=N_("Columns to unpivot"),
            description=N_("Empty: all other columns."),
            json_schema_extra={"widget": "columns"},
        )
        var_name: str = Field("variable", title=N_("Name of the column-name column"))
        value_name: str = Field("value", title=N_("Name of the value column"))

:fa-brands-github: Show source on GitHub