踩坑记录 2020-08-10 15:36 采纳率: 33.3%
浏览 126

tsfresh数据类型 unsupported operand type(s) for /: 'str' and 'int'

这是我的数据

图片说明

我想用tsfresh提取特征:

extraction_settings = ComprehensiveFCParameters()

x=extract_features(df,column_id='Magnorm',column_sort='index',
                   default_fc_parameters=extraction_settings,
                   impute_function=impute)

出现错误:

Feature Extraction:   0%|          | 0/10 [00:00<?, ?it/s]
---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/opt/conda/lib/python3.6/site-packages/tsfresh/utilities/distribution.py", line 39, in _function_with_partly_reduce
    results = list(itertools.chain.from_iterable(results))
  File "/opt/conda/lib/python3.6/site-packages/tsfresh/utilities/distribution.py", line 38, in <genexpr>
    results = (map_function(chunk, **kwargs) for chunk in chunk_list)
  File "/opt/conda/lib/python3.6/site-packages/tsfresh/feature_extraction/extraction.py", line 390, in _do_extraction_on_chunk
    return list(_f())
  File "/opt/conda/lib/python3.6/site-packages/tsfresh/feature_extraction/extraction.py", line 382, in _f
    result = [("", func(x))]
  File "/opt/conda/lib/python3.6/site-packages/tsfresh/feature_extraction/feature_calculators.py", line 193, in variance_larger_than_standard_deviation
    y = np.var(x)
  File "/opt/conda/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 3194, in var
    **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/numpy/core/_methods.py", line 105, in _var
    arrmean, rcount, out=arrmean, casting='unsafe', subok=False)
TypeError: unsupported operand type(s) for /: 'str' and 'int'
"""

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
<ipython-input-137-5deb0ecea4eb> in <module>()
      3 x=extract_features(df,column_id='Magnorm',column_sort='index',
      4                    default_fc_parameters=extraction_settings,
----> 5                    impute_function=impute)

/opt/conda/lib/python3.6/site-packages/tsfresh/feature_extraction/extraction.py in extract_features(timeseries_container, default_fc_parameters, kind_to_fc_parameters, column_id, column_sort, column_kind, column_value, chunksize, n_jobs, show_warnings, disable_progressbar, impute_function, profile, profiling_filename, profiling_sorting, distributor)
    158                                 default_fc_parameters=default_fc_parameters,
    159                                 kind_to_fc_parameters=kind_to_fc_parameters,
--> 160                                 distributor=distributor)
    161 
    162         # Impute the result if requested

/opt/conda/lib/python3.6/site-packages/tsfresh/feature_extraction/extraction.py in _do_extraction(df, column_id, column_value, column_kind, default_fc_parameters, kind_to_fc_parameters, n_jobs, chunk_size, disable_progressbar, show_warnings, distributor)
    309     result = distributor.map_reduce(_do_extraction_on_chunk, data=data_in_chunks,
    310                                     chunk_size=chunk_size,
--> 311                                     function_kwargs=kwargs)
    312     distributor.close()
    313 

/opt/conda/lib/python3.6/site-packages/tsfresh/utilities/distribution.py in map_reduce(self, map_function, data, function_kwargs, chunk_size, data_length)
    165             result = self.distribute(_function_with_partly_reduce, chunk_generator, map_kwargs),
    166 
--> 167         result = list(itertools.chain.from_iterable(result))
    168 
    169         return result

/opt/conda/lib/python3.6/site-packages/tqdm/_tqdm.py in __iter__(self)
    928 """, fp_write=getattr(self.fp, 'write', sys.stderr.write))
    929 
--> 930             for obj in iterable:
    931                 yield obj
    932                 # Update and possibly print the progressbar.

/opt/conda/lib/python3.6/multiprocessing/pool.py in next(self, timeout)
    733         if success:
    734             return value
--> 735         raise value
    736 
    737     __next__ = next                    # XXX

TypeError: unsupported operand type(s) for /: 'str' and 'int'

请问如何解决呢?

已经尝试过

df['Magnorm'] = df['Magnorm'].astype(float)
df['Magnorm'] = np.asarray(df['Magnorm'])
df['index'] = np.arange(df.shape[0])

没有用额

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2020-08-11 10:38
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿