Reputation: 605
My data look like this:
>df
Jan Feb March April
0 4 6 6 8
1 3 6 8 9
I am working with tslearn. Based on documentation, the data can be made into tslearn object as
from tslearn.utils import to_time_series_dataset
ts = to_time_series_dataset([df.iloc[0],df.iloc[1]])
which would be okay if I only had small number of rows. However I have about thousand. I tried to
for index, row in df.iterrows():
ts = to_time_series_dataset(row)
But the 'ts' from this only contain last row of dataframe.
Upvotes: 2
Views: 364
Reputation: 71580
Try using:
from tslearn.utils import to_time_series_dataset
ts = to_time_series_dataset([i for _,i in df.iterrows()])
Or use:
from tslearn.utils import to_time_series_dataset, load_timeseries_txt
ts = load_timeseries_txt('filename.txt')
Upvotes: 2