diff --git a/janitor/functions/_numba.py b/janitor/functions/_numba.py index 9ef4bb242..b0c8f2cef 100644 --- a/janitor/functions/_numba.py +++ b/janitor/functions/_numba.py @@ -166,7 +166,7 @@ def _numba_equi_join( # this also lets us know if there are equi matches keep_rows = slice_starts < slice_ends if not keep_rows.any(): - return None, None + return None if not keep_rows.all(): left_index = left_index[keep_rows] slice_starts = slice_starts[keep_rows] @@ -247,7 +247,7 @@ def _numba_equi_join( ) if left_index is None: - return None, None + return None return left_index, right_index @@ -571,14 +571,14 @@ def _numba_single_non_equi_join( left=left, right=right, op=op, multiple_conditions=False, keep=keep ) if outcome is None: - return None, None + return None return outcome outcome = _generic_func_cond_join( left=left, right=right, op=op, multiple_conditions=True, keep="all" ) if outcome is None: - return None, None + return None left_index, right_index, starts = outcome if op in less_than_join_types: counts = right_index.size - starts @@ -769,7 +769,7 @@ def _numba_multiple_non_equi_join( op=op, ) if result is None: - return None, None + return None ( left_index, right_index, @@ -800,7 +800,7 @@ def _numba_multiple_non_equi_join( booleans = starts == right_regions.shape[0] # left_region should be <= right_region if booleans.all(axis=None): - return None, None + return None if booleans.any(axis=None): booleans = ~booleans starts = starts[booleans] @@ -821,7 +821,7 @@ def _numba_multiple_non_equi_join( booleans = booleans.any(axis=1) if booleans.all(axis=None): - return None, None + return None if booleans.any(axis=None): booleans = ~booleans left_regions = left_regions[booleans] diff --git a/janitor/functions/conditional_join.py b/janitor/functions/conditional_join.py index 18734d487..0bd9e6bc7 100644 --- a/janitor/functions/conditional_join.py +++ b/janitor/functions/conditional_join.py @@ -543,8 +543,7 @@ def _conditional_join_compute( op=op, keep=keep, ) - if result[0] is None: - result = None + else: result = _generic_func_cond_join( left=df[left_on], @@ -767,7 +766,7 @@ def _multiple_conditional_join_eq( indices = _numba_equi_join( df=left_df, right=right_df, eqs=eqs, ge_gt=ge_gt, le_lt=le_lt ) - if indices[0] is None: + if indices is None: return None if not rest: return indices @@ -875,10 +874,7 @@ def _multiple_conditional_join_le_lt( condition for condition in conditions if condition not in gt_lt ] if (len(gt_lt) > 1) and not conditions: - result = _numba_multiple_non_equi_join(df, right, gt_lt, keep=keep) - if result[0] is None: - return None - return result + return _numba_multiple_non_equi_join(df, right, gt_lt, keep=keep) if len(gt_lt) == 1: left_on, right_on, op = gt_lt[0] indices = _numba_single_non_equi_join( @@ -888,7 +884,7 @@ def _multiple_conditional_join_le_lt( indices = _numba_multiple_non_equi_join( df, right, gt_lt, keep="all" ) - if indices[0] is None: + if indices is None: return None else: # there is an opportunity for optimization for range joins