dataframe icon indicating copy to clipboard operation
dataframe copied to clipboard

Moving/reordering inside groups near impossible

Open Jolanrensen opened this issue 6 months ago • 3 comments

In addition to https://github.com/Kotlin/dataframe/issues/1021 it's very difficuly to move/reorder columns inside a column group.

Let's say we have: Image

move to(Start) moves the column outside the group. This could do with a "keepInsideGroup" argument:

Image Image

We have move after, which works, but is a bit weird to use if you actually need a move before (which we don't have yet):

Image

"regrouping" doesn't work in one step; the order specified is not taken into account by selecting: Image

you would need to ungroup first, then regroup, requiring two steps...

Reordering does seem to work, but it's weird too because you need to "reorder by" something, so like the order in a list or a number:

Image Image

Jolanrensen avatar Jun 16 '25 10:06 Jolanrensen

IMO this ticket describes too different things. I'd keep only move to(Start) moves the column outside the group. This could do with a "keepInsideGroup" argument: proposal - it will be easier to decide

koperagen avatar Jun 16 '25 11:06 koperagen

This could do with a "keepInsideGroup" argument

Suggest shorter version: df.move { group.col }.toStart(insideGroup = true) df.move { group.col }.to(0, insideGroup = true)

On a second thought, not all selected columns can be from the same group :c

koperagen avatar Jun 16 '25 11:06 koperagen

IMO this ticket describes too different things. I'd keep only move to(Start) moves the column outside the group. This could do with a "keepInsideGroup" argument: proposal - it will be easier to decide

it describes one problem, namely changing the order of columns inside a group is hard. Wether that can be solved with reorder or move is up to how we want to implement it.

This could do with a "keepInsideGroup" argument

Suggest shorter version: df.move { group.col }.toStart(insideGroup = true) df.move { group.col }.to(0, insideGroup = true)

On a second thought, not all selected columns can be from the same group :c

hmm you're right, that's probably why we didn't do this already, but there are still options:

  • Create a move { group.singleCol }.to...() overload which gains the insideGroup argument
  • Create a new operation moveWithinGroup {}
  • Provide runtime errors when multiple columns are selected that don't have the same parent

Jolanrensen avatar Jun 16 '25 11:06 Jolanrensen

Hey, i would like to work on this issue.

CarloMariaProietti avatar Oct 09 '25 07:10 CarloMariaProietti

@CarloMariaProietti sure, give it a try :) However, this may be a more tricky issue as there are multiple possible solutions. Still, I think some of the ideas posed in this issue are worth exploring further.

The only thing we have to keep in mind is that we're nearing 1.0 and we're already at beta3, so any changes should be additive, meaning old functions should remain and behave similar to how they did; to keep binary compatibility and consistency with the compiler plugin. Similarly, we would need to keep code compatibility as much as possible; we cannot suddenly change the behavior when a user writes move { x }.to(0), for instance.

However, there are tools to maintain this compatibility. For instance, we have the command apiCheck which shows which functions were added (+) and which were deleted (-) (it's not perfect as it doesn't handle internal, @PublishedApi internal, and @Deprecated(level = HIDDEN) very well, but it's a good guide).

If it's not possible to achieve the goal without breaking things, that's fine as well, but then it will be a 1.1 goal instead.

I'm curious to see what you come up with :) thanks for all your contributions!

Jolanrensen avatar Oct 09 '25 10:10 Jolanrensen

I am glad to contribute and I hope to keep doing so! I would also like to work on this project in a more structured way, under the guidance of you and other maintainers.

CarloMariaProietti avatar Oct 10 '25 17:10 CarloMariaProietti

I implemented a solution for move to(Start) by creating an overload which gains the insideGroup argument. No existent function was modified so i hope i did not break consistency.

CarloMariaProietti avatar Oct 10 '25 17:10 CarloMariaProietti