def merge_interictal_preictal(interictal, preictal):
"""
Merges the *interictal* and *preictal* data frames to a single data frame. Also sorts the multilevel index.
:param interictal: A data frame containing the interictal samples.
:param preictal: A data frame containing the preictal samples.
:return: A data frame containing both interictal and preictal data. The multilevel index of the data frame
is sorted.
"""
logging.info("Merging interictal and preictal datasets")
try:
preictal.sortlevel('segment', inplace=True)
if isinstance(preictal.columns, pd.MultiIndex):
preictal.sortlevel(axis=1, inplace=True)
interictal.sortlevel('segment', inplace=True)
if isinstance(interictal.columns, pd.MultiIndex):
interictal.sortlevel(axis=1, inplace=True)
except TypeError:
logging.warning("TypeError when trying to merge interictal and preictal sets.")
dataset = pd.concat((interictal, preictal))
dataset.sortlevel('segment', inplace=True)
return dataset
评论列表
文章目录