Skip to content

Commit

Permalink
Fix Series __setitem__ and take (#3910)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Jul 6, 2022
1 parent c46f78b commit 467ab16
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions py-polars/polars/internals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,7 @@ def __setitem__(
s = wrap_s(PySeries.new_u32("", np.array(key, np.uint32), True))
self.__setitem__(s, value)
elif isinstance(key, (list, tuple)):
if not _NUMPY_AVAILABLE:
raise ImportError("'numpy' is required for this functionality.")
s = wrap_s(PySeries.new_u32("", np.array(key, np.uint32), True))
s = wrap_s(sequence_to_pyseries("", key, dtype=UInt32))
self.__setitem__(s, value)
elif isinstance(key, int) and not isinstance(key, bool):
self.__setitem__([key], value)
Expand Down Expand Up @@ -1538,10 +1536,6 @@ def take(self, indices: np.ndarray | list[int] | pli.Expr) -> Series:
"""
if isinstance(indices, pli.Expr):
return pli.select(pli.lit(self).take(indices)).to_series()
if isinstance(indices, list):
if not _NUMPY_AVAILABLE:
raise ImportError("'numpy' is required for this functionality.")
indices = np.array(indices)
return wrap_s(self._s.take(indices))

def null_count(self) -> int:
Expand Down

0 comments on commit 467ab16

Please sign in to comment.