diff options
author | Andrew <andrewgsavage@gmail.com> | 2022-10-01 02:37:40 +0100 |
---|---|---|
committer | Andrew <andrewgsavage@gmail.com> | 2022-10-01 02:37:40 +0100 |
commit | 35d8ad3c9c9161be4259c675d7031b8d49555398 (patch) | |
tree | e8beb36180e719692cc6a3bdf9fff775f32302ab /pint/facets | |
parent | 208d36a5bb051465296dad846296bb19628e2307 (diff) | |
download | pint-35d8ad3c9c9161be4259c675d7031b8d49555398.tar.gz |
adds ndim attribute for pandas compatability
Diffstat (limited to 'pint/facets')
-rw-r--r-- | pint/facets/plain/quantity.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pint/facets/plain/quantity.py b/pint/facets/plain/quantity.py index 5e4f33d..a36faa3 100644 --- a/pint/facets/plain/quantity.py +++ b/pint/facets/plain/quantity.py @@ -144,6 +144,12 @@ class PlainQuantity(PrettyIPython, SharedRegistryObject, Generic[_MagnitudeType] _magnitude: _MagnitudeType @property + def ndim(self) -> int: + if isinstance(self.magnitude, numbers.Number): + return 0 + return self.magnitude.ndim + + @property def force_ndarray(self) -> bool: return self._REGISTRY.force_ndarray |