Skip to content

Commit

Permalink
add is_list detection for merlin columns (#180)
Browse files Browse the repository at this point in the history
* add is_list detection for merlin columns

* fixing comment structure

* changed is list check for merlin column
  • Loading branch information
jperez999 authored Dec 9, 2022
1 parent 4f73ff5 commit c2ef3f0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions merlin/core/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2ef3f0

Please sign in to comment.