pythonpandasfeature-extraction

'DataFrame' object has no attribute 'time_series_features_extractor' using tsfel with python


So I'm working on a machine learning assignment in Python using google colab and I'm currently using pandas and tsfel for the feature extraction. The issue is that I can only run the feature extraction method(tsfel.time_series_feature_extracton()) once. Any other attempt to use the method again gives the error, "'DataFrame' object has no attribute 'time_series_features_extractor'". Any help on this would be greatly appreciated.

import pandas as pd
import tsfel

#just for clarification the df_time_wlk, df_sub_WLKFULL, df_WlkFull are dataframes

#config for the specific type of features I want to get
cfg=tsfel.get_features_by_domain('statistical')

#Making a new dataframe by copying two columns from another dataframe
t_time_wlk=df_WlkFull[['t_start','t_end']].copy()

#Extracting features from the new dataframe
#Running this first one works
tsfel = tsfel.time_series_features_extractor(cfg, t_time_wlk)
tsfel

#Extracting features from another dataframe
#This is where the error happens
sub_XYZ=tsfel.time_series_features_extractor(cfg,df_sub_WLKFULL)
sub_XYZ

Solution

  • You override tsfel:

    #         v-- the module       
    tsfel = tsfel.time_series_features_extractor(cfg, t_time_wlk)
    # ^-- now it's a dataframe
    

    Documentation:

    tsfel.feature_extraction.calc_features.time_series_features_extractor
    ...
    Returns: Extracted features
    Return type: DataFrame

    Solution: choose another name