Skip to content

Exception when calling updateGroups { it }.first().values() on GroupBy #1569

@Allex-Nik

Description

@Allex-Nik

Assume we have the following dataframe:

val df = dataFrameOf(
    "name" to columnOf("Alice", "Bob", "Charlie"),
    "age" to columnOf(15, 20, 25),
)

Calling

df.groupBy { age }.updateGroups { it }.first().values()

either in notebooks or outside them causes an exception. In notebooks this exception is formulated in the following way:

java.lang.IllegalStateException: Can not insert column age because column with this path already exists in DataFrame

If we remove age from every group:

df.groupBy { age }.updateGroups { it.remove { age } }.first().values()

the exception does not occur.

Notebooks

In notebooks, a similar problem occurs even without using values(). That is, calling:

df.groupBy { age }.updateGroups { it }.first()

causes:

The problem is found in one of the loaded libraries: check library renderers
java.lang.IllegalStateException: Can not insert column age because column with this path already exists in DataFrame
org.jetbrains.kotlinx.jupyter.exceptions.ReplLibraryException: The problem is found in one of the loaded libraries: check library renderers

If we add concat(), the exception does not occur:

df.groupBy { age }.updateGroups { it }.first().concat()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions