def spawn_dates_times(df, spawn_dates=True, spawn_times=False):
    """
    Build date/times column from a timeseries dataframe

    :param df: (pd.DataFrame) - dataframe with datetime index
    :param spawn_dates: (boolean) - whether to spawn year, month, day cols
    :param spawn_times: (boolean) - whether to spawn hour, minute, second cols
    :return df: (pd.DataFrame) - dataframe with datetime index
    """
    if spawn_dates:
        ind = df.index
        df = df.assign(year=ind.year, month=ind.month, day=ind.day)

    if spawn_times:
        ind = df.index
        df = df.assign(hour=ind.hour, minute=ind.minute, second=ind.second)

    return df