Giter VIP home page Giter VIP logo

Comments (3)

cmdlineluser avatar cmdlineluser commented on May 24, 2024

Yeah, it seems the warning only triggers for the "passing function by string name" case.

This doesn't warn - but I'm unsure if this use of count is deprecated also?

aggregate_function = pl.element().count()

Would the non-null len() need to be used instead?

aggregate_function = pl.element().drop_nulls().len()

from polars.

reswqa avatar reswqa commented on May 24, 2024

Before we rename pl.count to pl.len: pl.count() means the length of df, including the null value. But pl.count("a") equals to pl.col("a").count(), this doesn't include null value. This is sort of odd, so we rename the no-argument pl.count to pl.len.

If I remember correctly, aggregate_function='count' count the null value even when it is not deprecated(Because it actually uses pl.count() instead of pl.element().count()). You can manually use aggregate_function = pl.element().count() to achieve the behavior you expected. Of course, you could propose that aggregate_function=count shouldn't be deprecated and it's behave should be fixed as the same as pl.element().count().

from polars.

jsarbach avatar jsarbach commented on May 24, 2024

Yes, I propose this indeed, even if the workaround pl.element().count() works perfectly fine. I've seen #13673, but IMO the deprecation is not justified in this case. I've never come across a use case for including the nulls in a count in the context of a pivot, so if anything, the pl.element().count() behaviour should have priority over what len does.

If there is no support for un-deprecating count and implementing it as pl.element().count(), then I think the deprecation message should at least be changed so that it suggests using pl.element().count() if one is looking for a way to exclude the nulls.

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.