Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG/TST: added TypeError if object dtypes are detected in dataframe #61682

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sharkipelago
Copy link
Contributor

This PR addresses concern 1 of #55114 - Having consistent behavior with Series.round & DataFrame.round.

A TypeError is raised in a similar way to #61206.

I deleted test_round_mixed_type as I felt that test conflicted with the current intended behavior of DataFrame.round, but a little worried that might break some things, so any feedback is appreciated.

@sharkipelago
Copy link
Contributor Author

sharkipelago commented Jun 20, 2025

The second concern of the issue was round() did not work for Series or Dataframe when using decimal.Decimal from python's default decimal module. It seems like this is because both NumPy and pandas give array-like structures of decimal.Decimal objects a dtype of object. When I tested NumPy it raised an error on np.array([decimal.Decimal("1.2234242333234")]).round().

If the it the behavior of round() working with Series and DataFrames withdecimal.Decimal objects is still wanted, I thought a clean solution would be to make a new custom dtype for decimal.Decimal. However, that seemed like a pretty big change so wanted to check if there was another way I should be thinking about this bugfix.

@sharkipelago sharkipelago changed the title BUG/TST: added TypeError if object dtypes are dtected in dataframe BUG/TST: added TypeError if object dtypes are detected in dataframe Jun 20, 2025
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

Successfully merging this pull request may close these issues.

BUG: round not functioning as expected
1 participant