Skip to content

Commit

Permalink
fix issue hgrecco#165
Browse files Browse the repository at this point in the history
  • Loading branch information
burnpanck committed Jun 21, 2023
1 parent 07cbbbd commit 55381eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pint_pandas/pint_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,17 @@ def take(self, indices, allow_fill=False, fill_value=None):
Examples
--------
"""
from pandas.core.algorithms import take
from pandas.core.algorithms import take, is_scalar

data = self._data
if allow_fill and fill_value is None:
fill_value = self.dtype.na_value
if isinstance(fill_value, _Quantity):
fill_value = fill_value.to(self.units).magnitude
if not is_scalar(fill_value) and not fill_value.ndim:
# deal with Issue #165; for unit registries with force_ndarray_like = True,
# magnitude is in fact an array scalar, which will get rejected by pandas.
fill_value = fill_value[()]

result = take(data, indices, fill_value=fill_value, allow_fill=allow_fill)

Expand Down

0 comments on commit 55381eb

Please sign in to comment.