diff --git a/tests/units/utilities/test_dataframe_functions.py b/tests/units/utilities/test_dataframe_functions.py index 8181a976e..2d0f8bbad 100644 --- a/tests/units/utilities/test_dataframe_functions.py +++ b/tests/units/utilities/test_dataframe_functions.py @@ -138,6 +138,12 @@ def test_with_wrong_input(self): self.assertRaises(ValueError, dataframe_functions._normalize_input_to_internal_representation, test_df, None, None, None, "value") + test_df = pd.DataFrame([{"id": 0, "a_": 3, "b": 5, "sort": 1}]) + self.assertRaises(ValueError, dataframe_functions._normalize_input_to_internal_representation, test_df, "id", "sort", None, None) + + test_df = pd.DataFrame([{"id": 0, "a__c": 3, "b": 5, "sort": 1}]) + self.assertRaises(ValueError, dataframe_functions._normalize_input_to_internal_representation, test_df, "id", "sort", None, None) + test_df = pd.DataFrame([{"id": 0}]) self.assertRaises(ValueError, dataframe_functions._normalize_input_to_internal_representation, test_df, "id", None, None, None) diff --git a/tsfresh/utilities/dataframe_functions.py b/tsfresh/utilities/dataframe_functions.py index 8d9a59cbc..8f507da40 100644 --- a/tsfresh/utilities/dataframe_functions.py +++ b/tsfresh/utilities/dataframe_functions.py @@ -354,6 +354,14 @@ def _normalize_input_to_internal_representation(timeseries_container, column_id, # The kind columns should always be of type "str" to make the inference of feature settings later in `from_columns` # work timeseries_container[column_kind] = timeseries_container[column_kind].astype(str) + + # Make sure we have only parsable names + for kind in timeseries_container[column_kind].unique(): + if kind.endswith("_"): + raise ValueError("The kind {kind} is not allowed to end with '_'".format(kind=kind)) + if "__" in kind: + raise ValueError("The kind {kind} is not allowed to contain '__'".format(kind=kind)) + return timeseries_container, column_id, column_kind, column_value