Skip to content

DOC Add documentation for how pandas rounds values in Series.round and Dataframe.round methods #57981

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

Merged
merged 1 commit into from
Mar 24, 2024

Conversation

marenwestermann
Copy link
Contributor

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Description:
In the pandas documentation it is not documented how numbers are rounded if values are exactly halfway between rounded decimal values (they are rounded to the nearest even value). I added the documentation for this behaviour.

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @marenwestermann , this looks right

values = self.values.round(decimals) # type: ignore[union-attr]

and numpy documents it as rounding to the nearest even value. likewise pyarrow https://arrow.apache.org/docs/python/generated/pyarrow.compute.round.html

@MarcoGorelli MarcoGorelli added this to the 3.0 milestone Mar 24, 2024
@MarcoGorelli MarcoGorelli merged commit 4f145b3 into pandas-dev:main Mar 24, 2024
@marenwestermann
Copy link
Contributor Author

Thanks for the review @MarcoGorelli! Until next time! Bye!
Alt Text

@marenwestermann marenwestermann deleted the round-documentation branch March 25, 2024 08:05
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…d Dataframe.round methods (pandas-dev#57981)

add documentation for rounding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants