Skip to content
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

Units for .var, .std methods on offset units. #1640

Open
andrewgsavage opened this issue Oct 28, 2022 · 0 comments · May be fixed by #1992
Open

Units for .var, .std methods on offset units. #1640

andrewgsavage opened this issue Oct 28, 2022 · 0 comments · May be fixed by #1992

Comments

@andrewgsavage
Copy link
Collaborator

pint-pandas sets units for reductions on offset units incorrectly.

Statistical reductions like .std and .var compute quantities related to the spread of a distribution. As such, the result should always be a delta-unit (i.e. non-offset unit), regardless if the input has an offset or not. Currently, the result is wrongly reported with offset units if the input has offset units.
hgrecco/pint-pandas#94

I wanted to use the pint implementation, but that is also incorrect:

import pint
import numpy as np

q = pint.Quantity([1,2,4], "degC")

q.std() # OffsetUnitCalculusError
np.std(q) # OffsetUnitCalculusError
np.var(q) # OffsetUnitCalculusError

q.var() 
1.5555555555555554 degree_Celsius2
@andrewgsavage andrewgsavage linked a pull request May 21, 2024 that will close this issue
5 tasks
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 a pull request may close this issue.

1 participant