Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Provided in doc doesn't work #1027

Open
bbacasonati opened this issue Jun 12, 2023 · 1 comment
Open

Example Provided in doc doesn't work #1027

bbacasonati opened this issue Jun 12, 2023 · 1 comment
Labels

Comments

@bbacasonati
Copy link

The problem:
Hi!

I tried to run your example code, but it returned an error.
Here is the code that I executed :

`from tsfresh.examples.robot_execution_failures import download_robot_execution_failures,
load_robot_execution_failures
download_robot_execution_failures()
timeseries, y = load_robot_execution_failures()

from tsfresh import extract_features
extracted_features = extract_features(timeseries, column_id="id", column_sort="time")
`
Here is the returned error :

`
Feature Extraction: 100%|██████████| 10/10 [00:22<00:00, 2.28s/it]


TypeError Traceback (most recent call last)
Cell In[6], line 2
1 from tsfresh import extract_features
----> 2 extracted_features = extract_features(timeseries, column_id="id", column_sort="time")

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/tsfresh/feature_extraction/extraction.py:164, 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, pivot)
161 else:
162 warnings.simplefilter("default")
--> 164 result = _do_extraction(
165 df=timeseries_container,
166 column_id=column_id,
167 column_value=column_value,
168 column_kind=column_kind,
169 column_sort=column_sort,
170 n_jobs=n_jobs,
171 chunk_size=chunksize,
172 disable_progressbar=disable_progressbar,
173 show_warnings=show_warnings,
174 default_fc_parameters=default_fc_parameters,
175 kind_to_fc_parameters=kind_to_fc_parameters,
176 distributor=distributor,
177 pivot=pivot,
178 )
180 # Impute the result if requested
181 if impute_function is not None:

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/tsfresh/feature_extraction/extraction.py:304, in _do_extraction(df, column_id, column_value, column_kind, column_sort, default_fc_parameters, kind_to_fc_parameters, n_jobs, chunk_size, disable_progressbar, show_warnings, distributor, pivot)
301 if not pivot:
302 return result
--> 304 return_df = data.pivot(result)
305 return return_df

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/tsfresh/feature_extraction/data.py:94, in PartitionedTsData.pivot(self, results)
91 return_df = pd.DataFrame(return_df_dict, dtype=float)
93 # copy the type of the index
---> 94 return_df.index = return_df.index.astype(self.df_id_type)
96 # Sort by index to be backward compatible
97 return_df = return_df.sort_index()

File ~/anaconda3/envs/python3/lib/python3.10/site-packages/pandas/core/indexes/multi.py:3638, in MultiIndex.astype(self, dtype, copy)
3636 raise NotImplementedError(msg)
3637 if not is_object_dtype(dtype):
-> 3638 raise TypeError(
3639 "Setting a MultiIndex dtype to anything other than object "
3640 "is not supported"
3641 )
3642 if copy is True:
3643 return self._view()

TypeError: Setting a MultiIndex dtype to anything other than object is not supported
`

Environment:

  • Python version: 3.8
  • Operating System: Linux
  • tsfresh version: 0.20.0
  • Install method (conda, pip, source): pip
@nils-braun
Copy link
Collaborator

nils-braun commented Jun 14, 2023

Thanks @bbacasonati!
Are you by chance using pandas >= 2.0?
I have just released tsfresh version 0.20.1 which fixes this incompatibility with pandas 2.0.
Could you try again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants