Skip to content

[BUG] Component names are lost when using prepend_values  #2230

@dwolffram

Description

@dwolffram

Describe the bug
When using prepend_values the component names are lost.

To Reproduce

import numpy as np
from darts import concatenate
from darts.utils.timeseries_generation import linear_timeseries

series1 = linear_timeseries(start_value=1, end_value=2, start=0, length=10, freq=2, column_name='A')
series2 = linear_timeseries(start_value=2, end_value=3, start=0, length=10, freq=2, column_name='B')

series = concatenate([series1, series2], axis=1)
series.columns # returns Index(['A', 'B'], dtype='object', name='component')

prepended = series.prepend_values(np.array([[1, 2], [1, 2]]))
prepended.columns # returns Index(['0', '1'], dtype='object', name='component')

Expected behavior
prepended.columns should be the same as series.columns.

Additional context
This issue does not happen when append_values is used.

appended = series.append_values(np.array([[1, 2], [1, 2]]))
appended.columns # returns Index(['A', 'B'], dtype='object', name='component')

Probably it's enough to add columns=self.columns here: https://github.com/unit8co/darts/blob/master/darts/timeseries.py#L2875.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Released

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions