Skip to content

Pivot Plugin expanding non-numeric columns #38

@nickzoic

Description

@nickzoic

the Pivot Plugin can expand non-numeric columns but the defaults aren't particularly helpful:

x
y
z

  • Duplicate values are summed, which for strings means concatenated without separators.
  • Fill value is 0, which for string values is ugly.

pandas pivot_table can take an aggfunc per column, and only a scalar fill_value which defaults to NaN.

Possible options:

  • Use a friendlier aggfunc on string columns, even if it's just ','.join
  • (this is called to aggregate one or more values, but not zero values, so can't provide a custom fill_value)
  • Just raise an error/warning if there are index duplicates and a expand column is non-numeric
  • Use a null fillvalue but .fillna(0) on any columns which were numeric and .astype(int) to cast integer columns back to integers (or .map(lambda x: int(x or 0)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions