Skip to content

Commit

Permalink
fix!: if_else and case_when now return Series
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed Jul 18, 2022
1 parent 60f3e51 commit 003fc51
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions siuba/dply/verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,7 @@ def _if_else(__data, *args, **kwargs):
def _if_else(cond, true_vals, false_vals):
result = np.where(cond.fillna(False), true_vals, false_vals)

# TODO: should functions that take a Series, return a Series?
# for now, just return "O" type. Sort out once better research.
return result
return pd.Series(result)


# case_when ----------------
Expand Down Expand Up @@ -729,7 +727,7 @@ def case_when(__data, cases):
out[:] = val_res

# by recreating an array, attempts to cast as best dtype
return np.array(list(out))
return pd.Series(list(out))

@case_when.register(Symbolic)
@case_when.register(Call)
Expand Down

0 comments on commit 003fc51

Please sign in to comment.