Skip to content

Commit 72d5ca3

Browse files
author
samuel.oranyeli
committed
resolve conflicts
2 parents 5da4242 + 4da9a90 commit 72d5ca3

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

janitor/functions/conditional_join.py

+19-22
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pandas as pd
66
import pandas_flavor as pf
77
from pandas.core.dtypes.common import (
8-
is_categorical_dtype,
98
is_datetime64_dtype,
109
is_dtype_equal,
1110
is_extension_array_dtype,
@@ -336,29 +335,27 @@ def _conditional_join_type_check(
336335
"when use_numba is set to True"
337336
)
338337

339-
permitted_types = {
340-
is_datetime64_dtype,
341-
is_numeric_dtype,
342-
is_string_dtype,
343-
}
344-
for func in permitted_types:
345-
# change is based on this PR
346-
# https://github.com/pandas-dev/pandas/pull/52527/files
347-
if isinstance(left_column.dtype, pd.CategoricalDtype) or func(
348-
left_column
349-
):
350-
break
351-
else:
352-
raise TypeError(
353-
"conditional_join only supports "
354-
"string, category, numeric, or date dtypes (without timezone) - "
355-
f"'{left_column.name} is of type {left_column.dtype}."
356-
)
338+
is_categorical_dtype = isinstance(left_column.dtype, pd.CategoricalDtype)
357339

358-
lk_is_cat = is_categorical_dtype(left_column)
359-
rk_is_cat = is_categorical_dtype(right_column)
340+
if not is_categorical_dtype:
341+
permitted_types = {
342+
is_datetime64_dtype,
343+
is_numeric_dtype,
344+
is_string_dtype,
345+
}
346+
for func in permitted_types:
347+
if func(left_column.dtype):
348+
break
349+
else:
350+
raise TypeError(
351+
"conditional_join only supports "
352+
"string, category, numeric, or "
353+
"date dtypes (without timezone) - "
354+
f"'{left_column.name} is of type "
355+
f"{left_column.dtype}."
356+
)
360357

361-
if lk_is_cat & rk_is_cat:
358+
if is_categorical_dtype:
362359
if not left_column.array._categories_match_up_to_permutation(
363360
right_column.array
364361
):

0 commit comments

Comments
 (0)