提取功能时的tsfresh类型错误(Python)

时间:2017-07-17 15:54:06

标签: python dataframe types extract

当使用tsfresh提取相关功能时,我遇到了与类型有关的错误,但是我不知道为什么假设数据被构造为tsfresh所需的DataFrame。对此事的任何帮助都会很棒,谢谢!

提取功能的代码:

import pandas as pd
from tsfresh import extract_relevant_features as erf

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

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

错误:

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

1 个答案:

答案 0 :(得分:1)

尝试将y矢量转换为索引匹配x vector

的系列

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