-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I am failing to fit a SarimaxModel because the model reports that the exogenous and endogenous dataframes do not have the same index despite coming from the same dataframe.
After debugging, this seems to be due to the fact that the _get_transformed_data
method does not preserve the index using the default transformer
I have been able to correct this using
def _get_transformed_data(
self, as_series: bool = False
) -> Union[pandas.DataFrame, pandas.Series]:
key = self.node.key
value = self.node.item
transformed = self.transform_function.transform(value[key])
if as_series:
return pandas.Series(transformed, index=value[key].index)
else:
return pandas.DataFrame({key: transformed})
But perhaps it would be better to modify FunctionTransformer.transform
def transform(self, x: pandas.Series):
return self.func(x.values)
as this does not preserve the index of the input series
To Reproduce
from hts.model import SarimaxModel
tree = ...
model = SarimaxModel(node=tree)
#raises ValueError: The indices for endog and exog are not aligned
Expected behavior
No error should be raised because the two dataframes should have the same index
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working