Skip to content

Commit e6ebe3c

Browse files
committed
@fkiraly suggestion: add rule to differentiate nested_univ and Panel
1 parent e68a72d commit e6ebe3c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

sktime/datatypes/_panel/_check.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ def check_pdmultiindex_panel(obj, return_metadata=False, var_name="obj", panel=T
190190
msg = f"{var_name} must have a MultiIndex, found {type(obj.index)}"
191191
return _ret(False, msg, None, return_metadata)
192192

193+
# check to delineate from nested_univ mtype (Hierarchical)
194+
# pd.DataFrame mtype allows object dtype,
195+
# but if we allow object dtype with Panel entries,
196+
# the mtype becomes ambiguous, i.e., non-delineable from nested_univ
197+
if np.prod(obj.shape) > 0 and isinstance(obj.iloc[0, 0], (pd.Series, pd.DataFrame)):
198+
msg = f"{var_name} cannot contain nested pd.Series or pd.DataFrame"
199+
return _ret(False, msg, None, return_metadata)
200+
193201
index = obj.index
194202

195203
# check that columns are unique

0 commit comments

Comments
 (0)