Skip to content

gt_merge_stack doesn't seem work well with other parts of gt #166

Description

@avamsi

I'm trying to summarize some percentages along with counts providing context.

I considered the following options to merge the 2 (in my case 2 * N) columns:

  1. Wrap them in a custom object (with it's own repr) but that wouldn't work with GT(?).
  2. Serialize them as a string (with the same formatting I'd use in repr above) but that wouldn't work with data_color (though I suppose I could write my own helper using tab_style or something).
  3. Use gt_merge_stack (just came across it), which seems to be working well with data_color (great!) but seems to be breaking at least autocolor_text and fmt_number.

Are there any other solutions to what I'm trying to do? If not, do you think this is a reasonable feature request?

Example:

(
    GT(pl.DataFrame(dict(a=[1 / 2, 2 / 3, 3 / 4, 4 / 5], b=[4] * 4)))
    .data_color(c.a, palette="GnBu")
)
(
    GT(pl.DataFrame(dict(a=[1 / 2, 2 / 3, 3 / 4, 4 / 5], b=[4] * 4)))
    .pipe(gte.gt_merge_stack, c.a, c.b)
    .data_color(c.a, palette="GnBu")
)
Image

^ Notice the difference in precision and text colors (I do realize gt_merge_stack has it's own colors and is likely overriding colors from data_color, but I hope they can be made to work well with each other).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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