Giter Site home page Giter Site logo

Comments (3)

rhshadrach avatar rhshadrach commented on September 26, 2024 1

Should I insert that here at current L97?

I think this should go in the notes section which is below See Also; L190 here.

When you say hash-based, I assume this means that it always uses hash()? eq() is never considered? Should this be mentioned?

No - hash is used to produce a non-necessarily unique but often distinct number; __eq__ is then used in the case of conflicts. This is why a requirement for writing a hash function is that two objects that are equal must have equal hashes.

I also just realized that the string workaround obviously has its own drawbacks, as it would now group the string '1' and the int 1 as equals, but I guess we don't have to provide a general solution.

That's a good point - this makes me quite hesitant to mention the workaround.

from pandas.

rhshadrach avatar rhshadrach commented on September 26, 2024

Thanks for the report, I think a line in the notes section of the docstring on DataFrame.groupby and Series.groupby would be appropriate, something like:

The implementation of groupby is hash-based, meaning in particular that objects that compare as equal will be considered as the same group. An exception to this is that pandas has special handling of NA values: any NA values will be collapsed to a single group, regardless of how they compare. See the user guide for more details.

An example in the user guide and your suggested workaround could then be linked to in the last sentence.

Would you be interested in submitting a PR?

from pandas.

gabuzi avatar gabuzi commented on September 26, 2024

Thanks for the suggestion. I'd be happy to open a PR on this. Should I insert that here at current L97?

used to group large amounts of data and compute operations on these
groups.
Parameters
----------

Should I add an example?

I just have another follow-up question: When you say hash-based, I assume this means that it always uses __hash__()? __eq__() is never considered? Should this be mentioned? Maybe in the linked user guide? The implication is that a simple a == b test during debugging as I did above is not actually the right thing to look at (although proper code should maintain a.__eq__(b) == True => a.__hash__() == b.__hash__(), but bugs do happen...).

I also just realized that the string workaround obviously has its own drawbacks, as it would now group the string '1' and the int 1 as equals, but I guess we don't have to provide a general solution.

from pandas.

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.