Closed rwijtvliet closed 3 months ago
Basically, recreate the Series. Maybe it's helpful in the bugfix.
# Workaround:
pd.Series(-s_units.pint.m).astype(f'pint[{s_units.pint.units}]')
# a -0.380723445919278
# b -0.7774489057875323
# dtype: pint[megawatt_hour]
For Dataframes, an issue with __neg__
also exists, but slightly different. Also, the workaround is a bit more readable and doesn't require referencing the object twice:
(-df.pint.dequantify()).pint.quantify()
Looks like the starting point for a PR here would be in Pandas, pandas/core/arrays/base.py ExtensionOpsMixin and the definition of a _create_unary_arith_method or some such.