Skip to content

Commit

Permalink
ensure booleans are converted into arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
samukweku committed Nov 7, 2022
1 parent d80baf3 commit 78620cb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions janitor/functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def _index_dispatch(arg, df, axis): # noqa: F811
f"{arg} is a boolean dtype and has wrong length: "
f"{len(arg)} instead of {len(index)}"
)
return arg
return np.asanyarray(arg)
try:

if isinstance(arg, pd.Series):
Expand Down Expand Up @@ -540,11 +540,12 @@ def _index_dispatch(arg, df, axis): # noqa: F811
# or materialized if possible;
# this offers more performance
if len(indices) == 1:
if isinstance(indices[0], int):
if is_scalar(indices[0]):
return indices
if is_list_like(indices[0]):
return np.asanyarray(indices[0])
return indices[0]
indices = indices[0]
if is_list_like(indices):
indices = np.asanyarray(indices)
return indices
contents = []
for arr in indices:
if is_list_like(arr):
Expand Down

0 comments on commit 78620cb

Please sign in to comment.