user8188120
user8188120

Reputation: 915

tsfresh type error when extracting features (Python)

When using tsfresh to extract relevant features I encounter an error to do with type however I don't know why given that the data was constructed as a DataFrame which is what tsfresh requires. Any help on this matter would be great, thanks!

Code to extract features:

import pandas as pd
from tsfresh import extract_relevant_features as erf

features = erf(gathered_data,"flux", column_id = "ids",column_sort = "phase")

The DataFrame:

        ids     phase      flux
0    5675.0  0.000309  0.953494
1    5675.0  0.004631  0.987416
2    5675.0  0.005644  0.975253
3    5675.0  0.006582  0.978103
4    5675.0  0.007492  0.978654
5    5675.0  0.008450  0.967306
6    5675.0  0.009491  0.966675
7    5675.0  0.014796  0.973056
8    5675.0  0.015579  0.960849
9    5675.0  0.016254  0.963274
10   5675.0  0.017343  0.960005
11   5675.0  0.018439  0.962337
12   5675.0  0.019481  0.974755
13   5675.0  0.024558  0.971611
14   5675.0  0.025262  0.972203
15   5675.0  0.026529  0.973336
16   5675.0  0.027216  0.978327
17   5675.0  0.028310  0.976190
18   5675.0  0.033552  0.972871
19   5675.0  0.034512  0.976207
20   5675.0  0.035494  0.975664
21   5675.0  0.037345  0.969312
22   5675.0  0.038524  0.964423
23   5675.0  0.043678  0.963922
24   5675.0  0.044833  0.970770
25   5675.0  0.045642  0.954368
26   5675.0  0.046471  0.967965
27   5675.0  0.047680  0.962106
28   5675.0  0.053614  0.962091
29   5675.0  0.055518  0.971543

The error:

TypeError: The type of target vector y must be one of: pandas.Series, numpy.ndarray

Upvotes: 1

Views: 1135

Answers (1)

nitroz
nitroz

Reputation: 36

try this to convert y vector to a series with index matching x vector

y = pd.Series(gathered_data['flux'], index=gathered_data.ids)

Upvotes: 2

Related Questions