Giter Site home page Giter Site logo

Comments (11)

mirkomiorelli avatar mirkomiorelli commented on August 18, 2024

When adding maintain_order=True to the .group_by(pl.col('disk_hex')) call, the nondeterminism of the grouping appears to cease, but the resulting dataframe still includes duplicate values within the Disk ID column.

I am having the same issue working with dataframes larger than 20K records. I found that adding a sort operation on the grouping col before the group by solves the non-deterministic and non-uniqueness behavior for me on 0.20.11. E.g., in_ the gist, adding .sort(by='disk_hex') before the .group_by(pl.col('disk_hex')) I think returns the expected result if I am interpreting the log correctly.

from polars.

seanlane avatar seanlane commented on August 18, 2024

@mirkomiorelli I'm seeing that as well, adding .sort(by='disk_hex') before the .group_by(pl.col('disk_hex')) returns the expected number of rows (17,148). This also corrects the issue when grouping on a larger dataframe with greater than 250,000 rows as well.

from polars.

jmoralez avatar jmoralez commented on August 18, 2024

I'm seeing something similar for max().over(), it seems to be when the input isn't sorted and happens when n_rows > 1,000. Here's a minimal example:

import numpy as np
import polars as pl

n_groups = 250
rows_per_group = 4
(
    pl.DataFrame(
        {
            'grp': np.repeat(np.arange(n_groups), rows_per_group),
            'x': np.tile(np.arange(rows_per_group), n_groups)
        }
    )
    .sample(fraction=1.0, shuffle=True)
    .select(pl.col('x').max().over('grp'))
    ['x']
    .value_counts()
)

at 1,000 samples this returns the expected

# x	count
# i64	u32
# 3	1000

but at 1,004 (n_groups=251) it returns the following:

# x	count
# i64	u32
# 2	269
# 1	150
# 3	493
# 0	92

from polars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.