Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill null with previous value not cascading values #1008

Open
francosang opened this issue Dec 29, 2024 · 0 comments
Open

Fill null with previous value not cascading values #1008

francosang opened this issue Dec 29, 2024 · 0 comments

Comments

@francosang
Copy link

francosang commented Dec 29, 2024

Given this code:

val csv = """
        Name,Belongings
        Peter,TV
        ,Phone
        ,Car
        Andy,
        Mary,House
        ,Boat
        ,Dog
        ,Laptop
    """.trimIndent().toInputStream()

DataFrame.readCSV(csv)
    .fillNulls("Name").with { prev()?.get("Name") }
    .forEach { println(it) }

Current output:

{ Name:Peter, Belongings:TV }
{ Name:Peter, Belongings:Phone }
{ Belongings:Car }
{ Name:Andy }
{ Name:Mary, Belongings:House }
{ Name:Mary, Belongings:Boat }
{ Belongings:Dog }
{ Belongings:Laptop }

When the row index 1 (value ,Phone) is reached, the fill with block is executed and the previous row (index 0 Peter,TV) contains the Name as expected.
But it seems that for the next row (index 2 ,Car), the previous row does not contain the value that was filled previously.

Expected output:

{ Name:Peter, Belongings:TV }
{ Name:Peter, Belongings:Phone }
{ Name:Peter, Belongings:Car }
{ Name:Andy }
{ Name:Mary, Belongings:House }
{ Name:Mary, Belongings:Boat }
{ Name:Mary, Belongings:Dog }
{ Name:Mary, Belongings:Laptop }

Version:

implementation("org.jetbrains.kotlinx:dataframe:0.15.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant