From c2ef3f06ce2caf864d84bc6e92799c4d1392f74a Mon Sep 17 00:00:00 2001 From: Julio Perez <37191411+jperez999@users.noreply.github.com> Date: Fri, 9 Dec 2022 12:06:57 -0500 Subject: [PATCH] add is_list detection for merlin columns (#180) * add is_list detection for merlin columns * fixing comment structure * changed is list check for merlin column --- merlin/core/dispatch.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/merlin/core/dispatch.py b/merlin/core/dispatch.py index f365fe515..d9aa6ab23 100644 --- a/merlin/core/dispatch.py +++ b/merlin/core/dispatch.py @@ -293,11 +293,17 @@ def list_val_dtype(ser: SeriesLike) -> np.dtype: return pd.core.dtypes.cast.infer_dtype_from(next(iter(pd.core.common.flatten(ser))))[0] if isinstance(ser, np.ndarray): return ser.dtype + # adds detection when in merlin column + if hasattr(ser, "is_list"): + return ser[0].dtype return None def is_list_dtype(ser): """Check if Series contains list elements""" + # adds detection for merlin column + if hasattr(ser, "is_list"): + return ser.is_list if isinstance(ser, pd.Series): if not len(ser): # pylint: disable=len-as-condition return False