def _merge_clustered_items(cluster_set: np.array, labels: np.array, data: Union[(pd.DataFrame, np.array)], time_column: str, counts: np.array) -> pd.DataFrame:
    '\n    Merge outliers and core clusters into single DataFrame.\n\n    Parameters\n    ----------\n    cluster_set : np.array\n        The set of clusters\n    labels : np.array\n        The cluster labels\n    data : Union[pd.DataFrame, np.array]\n        The source data\n    time_column : str\n        Name of the Time column\n    counts : np.array\n        The counts of members in each cluster\n\n    Returns\n    -------\n    pd.DataFrame\n        Merged dataframe\n\n    '
    tz_aware = data.iloc[0][time_column].tz
    ts_type = ('datetime64[ns, UTC]' if (tz_aware is not None) else 'datetime64[ns]')
    cluster_list = []
    for idx in range(len(cluster_set)):
        cluster_id = cluster_set[idx]
        class_members = (labels == cluster_id)
        if isinstance(data, pd.DataFrame):
            time_ordered = data[class_members].sort_values(time_column, ascending=True)
            first_event_time = time_ordered[0:][time_column].iat[0]
            last_event_time = time_ordered[(- 1):][time_column].iat[0]
        else:
            first_event_time = None
            last_event_time = None
        if (cluster_id == (- 1)):
            cluster_list.append(data[class_members].assign(Clustered=False, ClusterId=cluster_id, ClusterSize=1, TimeGenerated=first_event_time, FirstEventTime=first_event_time, LastEventTime=last_event_time).astype(dtype={'TimeGenerated': ts_type, 'FirstEventTime': ts_type, 'LastEventTime': ts_type}))
        else:
            cluster_list.append(data[class_members].assign(Clustered=True, ClusterId=cluster_id, ClusterSize=counts[idx], TimeGenerated=first_event_time, FirstEventTime=first_event_time, LastEventTime=last_event_time)[0:1].astype(dtype={'TimeGenerated': ts_type, 'FirstEventTime': ts_type, 'LastEventTime': ts_type}))
    return pd.concat(cluster_list)
Merge outliers and core clusters into single DataFrame.

Parameters
----------
cluster_set : np.array
    The set of clusters
labels : np.array
    The cluster labels
data : Union[pd.DataFrame, np.array]
    The source data
time_column : str
    Name of the Time column
counts : np.array
    The counts of members in each cluster

Returns
-------
pd.DataFrame
    Merged dataframe
def _merge_clustered_items(cluster_set: np.array, labels: np.array, data: Union[(pd.DataFrame, np.array)], time_column: str, counts: np.array) -> pd.DataFrame:
    '\n    Merge outliers and core clusters into single DataFrame.\n\n    Parameters\n    ----------\n    cluster_set : np.array\n        The set of clusters\n    labels : np.array\n        The cluster labels\n    data : Union[pd.DataFrame, np.array]\n        The source data\n    time_column : str\n        Name of the Time column\n    counts : np.array\n        The counts of members in each cluster\n\n    Returns\n    -------\n    pd.DataFrame\n        Merged dataframe\n\n    '
    tz_aware = data.iloc[0][time_column].tz
    ts_type = ('datetime64[ns, UTC]' if (tz_aware is not None) else 'datetime64[ns]')
    cluster_list = []
    for idx in range(len(cluster_set)):
        cluster_id = cluster_set[idx]
        class_members = (labels == cluster_id)
        if isinstance(data, pd.DataFrame):
            time_ordered = data[class_members].sort_values(time_column, ascending=True)
            first_event_time = time_ordered[0:][time_column].iat[0]
            last_event_time = time_ordered[(- 1):][time_column].iat[0]
        else:
            first_event_time = None
            last_event_time = None
        if (cluster_id == (- 1)):
            cluster_list.append(data[class_members].assign(Clustered=False, ClusterId=cluster_id, ClusterSize=1, TimeGenerated=first_event_time, FirstEventTime=first_event_time, LastEventTime=last_event_time).astype(dtype={'TimeGenerated': ts_type, 'FirstEventTime': ts_type, 'LastEventTime': ts_type}))
        else:
            cluster_list.append(data[class_members].assign(Clustered=True, ClusterId=cluster_id, ClusterSize=counts[idx], TimeGenerated=first_event_time, FirstEventTime=first_event_time, LastEventTime=last_event_time)[0:1].astype(dtype={'TimeGenerated': ts_type, 'FirstEventTime': ts_type, 'LastEventTime': ts_type}))
    return pd.concat(cluster_list)